"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const event = require("../../../base/common/event.js");
const lifecycle = require("../../../base/common/lifecycle.js");
const instantiation = require("../../instantiation/common/instantiation.js");
const ILogService = instantiation.createDecorator("logService");
exports.LogLevel = void 0;
(function(LogLevel) {
  LogLevel[LogLevel["Trace"] = 0] = "Trace";
  LogLevel[LogLevel["Debug"] = 1] = "Debug";
  LogLevel[LogLevel["Info"] = 2] = "Info";
  LogLevel[LogLevel["Warning"] = 3] = "Warning";
  LogLevel[LogLevel["Error"] = 4] = "Error";
  LogLevel[LogLevel["Critical"] = 5] = "Critical";
  LogLevel[LogLevel["Off"] = 6] = "Off";
})(exports.LogLevel || (exports.LogLevel = {}));
const DEFAULT_LOG_LEVEL = exports.LogLevel.Info;
class AbstractLogger extends lifecycle.Disposable {
  constructor() {
    super(...arguments);
    this.level = DEFAULT_LOG_LEVEL;
    this._onDidChangeLogLevel = this._register(new event.Emitter());
  }
  setLevel(level) {
    if (this.level !== level) {
      this.level = level;
      this._onDidChangeLogLevel.fire(this.level);
    }
  }
  getLevel() {
    return this.level;
  }
}
class ConsoleLogger extends AbstractLogger {
  constructor(logLevel = DEFAULT_LOG_LEVEL) {
    super();
    this.setLevel(logLevel);
  }
  trace(message, ...args) {
    if (this.getLevel() <= exports.LogLevel.Trace) {
      console.log("%cTRACE", "color: #888", message, ...args);
    }
  }
  debug(message, ...args) {
    if (this.getLevel() <= exports.LogLevel.Debug) {
      console.log("%cDEBUG", "background: #eee; color: #888", message, ...args);
    }
  }
  info(message, ...args) {
    if (this.getLevel() <= exports.LogLevel.Info) {
      console.log("%c INFO", "color: #33f", message, ...args);
    }
  }
  error(message, ...args) {
    if (this.getLevel() <= exports.LogLevel.Error) {
      console.log("%c  ERR", "color: #f33", message, ...args);
    }
  }
  dispose() {
  }
}
class LogService extends lifecycle.Disposable {
  constructor(logger) {
    super();
    this.logger = logger;
    this._register(logger);
  }
  getLevel() {
    return this.logger.getLevel();
  }
  trace(message, ...args) {
    this.logger.trace(message, ...args);
  }
  debug(message, ...args) {
    this.logger.debug(message, ...args);
  }
  info(message, ...args) {
    this.logger.info(message, ...args);
  }
  error(message, ...args) {
    this.logger.error(message, ...args);
  }
}
exports.AbstractLogger = AbstractLogger;
exports.ConsoleLogger = ConsoleLogger;
exports.DEFAULT_LOG_LEVEL = DEFAULT_LOG_LEVEL;
exports.ILogService = ILogService;
exports.LogService = LogService;
