"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LMLogger = void 0;
const infinite_react_1 = require("@infinite-table/infinite-react");
const performanceTime = (previousTime) => {
    const now = performance.now();
    return Math.round(previousTime ? now - previousTime : now);
};
class LMLogger {
    debugger;
    infoLogger;
    successLogger;
    warnLogger;
    errorLogger;
    perfLogger;
    debugId;
    constructor(options) {
        this.debugId = options.debugId;
        this.debugger = (0, infinite_react_1.debug)(this.debugId ? `LayoutManager:${this.debugId}` : 'LayoutManager');
        this.infoLogger = this.debugger.extend(`info`);
        this.infoLogger.logFn = console.info.bind(console);
        this.successLogger = this.debugger.extend(`success`);
        this.successLogger.logFn = console.log.bind(console);
        this.warnLogger = this.debugger.extend(`warn`);
        this.warnLogger.logFn = console.warn.bind(console);
        this.errorLogger = this.debugger.extend(`error`);
        this.errorLogger.logFn = console.error.bind(console);
        this.perfLogger = this.debugger.extend(`perf`);
        this.perfLogger.logFn = console.info.bind(console);
    }
    beginPerf(sectionName) {
        this.perfLogger(`[BEGIN] - ${sectionName}`);
        const startTime = performanceTime();
        return {
            end: (additionalComment) => {
                this.perfLogger(`[END]   - ${sectionName} ${additionalComment ? `(${additionalComment})` : ''} :: [delta +${performanceTime(startTime)}ms]`);
            },
        };
    }
    info(message, ...optionalParams) {
        if (optionalParams?.length) {
            this.infoLogger(message, ...optionalParams);
        }
        else {
            this.infoLogger(message);
        }
    }
    success(message, ...optionalParams) {
        if (optionalParams?.length) {
            this.successLogger(message, ...optionalParams);
        }
        else {
            this.successLogger(message);
        }
    }
    warn(message, ...optionalParams) {
        if (optionalParams?.length) {
            this.warnLogger(message, ...optionalParams);
        }
        else {
            this.warnLogger(message);
        }
    }
    error(message, ...optionalParams) {
        if (optionalParams?.length) {
            this.errorLogger(message, ...optionalParams);
        }
        else {
            this.errorLogger(message);
        }
    }
}
exports.LMLogger = LMLogger;
