"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = void 0;
exports.setLogLevel = setLogLevel;
exports.log = log;
const LEVEL_PRIORITY = {
    debug: 0,
    info: 1,
    warn: 2,
    error: 3,
};
let minLevel = 'info';
function setLogLevel(level) {
    minLevel = level;
}
function log(level, component, message, data) {
    if (LEVEL_PRIORITY[level] < LEVEL_PRIORITY[minLevel])
        return;
    const timestamp = new Date().toISOString();
    const prefix = `[${timestamp}] [${level.toUpperCase().padEnd(5)}] [${component}]`;
    const suffix = data ? ` ${JSON.stringify(data)}` : '';
    const line = `${prefix} ${message}${suffix}`;
    switch (level) {
        case 'error':
            console.error(line);
            break;
        case 'warn':
            console.warn(line);
            break;
        default:
            console.log(line);
    }
}
exports.logger = {
    debug: (component, msg, data) => log('debug', component, msg, data),
    info: (component, msg, data) => log('info', component, msg, data),
    warn: (component, msg, data) => log('warn', component, msg, data),
    error: (component, msg, data) => log('error', component, msg, data),
};
//# sourceMappingURL=logger.js.map