"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.memoryLogger = void 0;
const MAX_LOG_BUFFER = 200;
const logBuffer = [];
function addLogEntry(level, message, data) {
    const entry = {
        timestamp: Date.now(),
        level,
        message,
        data
    };
    logBuffer.push(entry);
    if (logBuffer.length > MAX_LOG_BUFFER) {
        logBuffer.shift();
    }
    const timestamp = new Date(entry.timestamp).toISOString();
    const prefix = `[${timestamp}] [${level.toUpperCase()}]`;
    switch (level) {
        case 'error':
            console.error(`${prefix} ${message}`, data || '');
            break;
        case 'warn':
            console.warn(`${prefix} ${message}`, data || '');
            break;
        case 'info':
            console.log(`${prefix} ${message}`, data || '');
            break;
        case 'debug':
            console.debug(`${prefix} ${message}`, data || '');
            break;
    }
}
exports.memoryLogger = {
    error: (message, data) => {
        addLogEntry('error', message, data);
    },
    warn: (message, data) => {
        addLogEntry('warn', message, data);
    },
    info: (message, data) => {
        addLogEntry('info', message, data);
    },
    debug: (message, data) => {
        addLogEntry('debug', message, data);
    },
    getLogs(limit) {
        const logs = [...logBuffer];
        if (limit && limit > 0) {
            return logs.slice(-limit);
        }
        return logs;
    },
    clear() {
        logBuffer.length = 0;
    },
    size() {
        return logBuffer.length;
    }
};
//# sourceMappingURL=memory-logger.js.map