"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setLogLevel = exports.getLogLevel = exports.LOG_LEVELS = void 0;
const chalk_1 = __importDefault(require("chalk"));
const winston_1 = __importDefault(require("winston"));
exports.LOG_LEVELS = {
    error: 0,
    warn: 1,
    info: 2,
    debug: 3,
};
const customFormatter = winston_1.default.format.printf(({ level, message, ...args }) => {
    if (level === 'error') {
        return chalk_1.default.red(message);
    }
    else if (level === 'warn') {
        return chalk_1.default.yellow(message);
    }
    else if (level === 'info') {
        return message;
    }
    else if (level === 'debug') {
        return chalk_1.default.cyan(message);
    }
    throw new Error(`Invalid log level: ${level}`);
});
const logger = winston_1.default.createLogger({
    levels: exports.LOG_LEVELS,
    format: winston_1.default.format.combine(winston_1.default.format.simple(), customFormatter),
    transports: [
        new winston_1.default.transports.Console({
            level: process.env.LOG_LEVEL || 'info',
        }),
    ],
});
function getLogLevel() {
    return logger.transports[0].level;
}
exports.getLogLevel = getLogLevel;
function setLogLevel(level) {
    if (level in exports.LOG_LEVELS) {
        logger.transports[0].level = level;
    }
    else {
        throw new Error(`Invalid log level: ${level}`);
    }
}
exports.setLogLevel = setLogLevel;
exports.default = logger;
//# sourceMappingURL=logger.js.map