"use strict";
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const debug = require("debug");
const LIB_NAME = "det";
const NAMEPACE_SEPARATOR = "/";
const Level = {
  Debug: "debug",
  Error: "error",
  Info: "info",
  Trace: "trace",
  Warn: "warn"
};
const generateNamespace = (parts, separator = NAMEPACE_SEPARATOR) => {
  return parts.join(separator);
};
const loggers = {};
const getLogger = (namespace, level) => {
  const key = `${namespace}:${level}`;
  if (!loggers[key]) {
    loggers[key] = debug.debug(key);
  }
  return loggers[key];
};
class Logger {
  constructor(namespace) {
    __publicField(this, "namespace");
    this.namespace = namespace;
  }
  extend(...namespace) {
    return new Logger(generateNamespace([this.namespace, ...namespace]));
  }
  debug(...msg) {
    this.logWithLevel(Level.Debug, ...msg);
  }
  trace(...msg) {
    this.logWithLevel(Level.Trace, ...msg);
  }
  info(...msg) {
    this.logWithLevel(Level.Info, ...msg);
  }
  error(...msg) {
    this.logWithLevel(Level.Error, ...msg);
  }
  warn(...msg) {
    this.logWithLevel(Level.Warn, ...msg);
  }
  logWithLevel(level, ...msg) {
    getLogger(this.namespace, level)(...msg);
  }
}
const rootLogger = new Logger(LIB_NAME);
exports.Level = Level;
exports.NAMEPACE_SEPARATOR = NAMEPACE_SEPARATOR;
exports.default = rootLogger;
exports.getLogger = getLogger;
