"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var events_1 = require("events");
var DeviceLogProvider = (function (_super) {
    __extends(DeviceLogProvider, _super);
    function DeviceLogProvider($logFilter) {
        _super.call(this);
        this.$logFilter = $logFilter;
        this.devicesLogLevel = {};
    }
    DeviceLogProvider.prototype.logData = function (line, platform, deviceIdentifier) {
        var logLevel = this.$logFilter.loggingLevel;
        if (deviceIdentifier) {
            logLevel = this.devicesLogLevel[deviceIdentifier] = this.devicesLogLevel[deviceIdentifier] || this.$logFilter.loggingLevel;
        }
        var data = this.$logFilter.filterData(platform, line, logLevel);
        if (data) {
            this.emit('data', deviceIdentifier, data);
        }
    };
    DeviceLogProvider.prototype.setLogLevel = function (logLevel, deviceIdentifier) {
        var _this = this;
        if (deviceIdentifier) {
            this.devicesLogLevel[deviceIdentifier] = logLevel.toUpperCase();
        }
        else {
            this.$logFilter.loggingLevel = logLevel.toUpperCase();
            _.each(this.devicesLogLevel, function (deviceLogLevel, deviceId) {
                _this.devicesLogLevel[deviceId] = _this.$logFilter.loggingLevel;
            });
        }
    };
    return DeviceLogProvider;
})(events_1.EventEmitter);
exports.DeviceLogProvider = DeviceLogProvider;
$injector.register("deviceLogProvider", DeviceLogProvider);
