"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsoleLogger = exports.LoggerBase = exports.Logger = exports.LOG_LEVELS = void 0;
exports.LOG_LEVELS = ['debug', 'info', 'warn', 'error', 'mute'];
class Logger {
}
exports.Logger = Logger;
class LoggerBase extends Logger {
    constructor() {
        super(...arguments);
        this.contextData = {};
        this.level = 'info';
    }
    log(level, message, details) {
        if (level === 'mute' || exports.LOG_LEVELS.indexOf(level) < exports.LOG_LEVELS.indexOf(this.level)) {
            return;
        }
        this.write(level, message, details);
    }
    info(message, details = {}) {
        this.log('info', message, details);
    }
    warn(message, details = {}) {
        this.log('warn', message, details);
    }
    error(message, details = {}) {
        this.log('error', message, details);
    }
    debug(message, details = {}) {
        this.log('debug', message, details);
    }
}
exports.LoggerBase = LoggerBase;
class ConsoleLogger extends LoggerBase {
    constructor() {
        super();
        const level = (process.env.LOG_LEVEL || 'info');
        this.level = exports.LOG_LEVELS.includes(level) ? level : 'info';
    }
    write(level, message, details) {
        if (level === 'mute') {
            return;
        }
        return console[level](message, details);
    }
    child(data) {
        const child = new ConsoleLogger();
        child.level = this.level;
        child.contextData = { ...this.contextData, ...data };
        return child;
    }
}
exports.ConsoleLogger = ConsoleLogger;
//# sourceMappingURL=logger.js.map