"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HotLog = exports.HotLogLevel = void 0;
/**
 * The logging level.
 */
var HotLogLevel;
(function (HotLogLevel) {
    /**
     * Prints only info messages.
     */
    HotLogLevel[HotLogLevel["Info"] = 0] = "Info";
    /**
     * Prints only warning messages.
     */
    HotLogLevel[HotLogLevel["Warning"] = 1] = "Warning";
    /**
     * Prints only error messages.
     */
    HotLogLevel[HotLogLevel["Error"] = 2] = "Error";
    /**
     * Prints all messages.
     */
    HotLogLevel[HotLogLevel["Verbose"] = 3] = "Verbose";
    /**
     * Prints all messages, except verbose.
     */
    HotLogLevel[HotLogLevel["All"] = 4] = "All";
    /**
     * Doesn't print any message.
     */
    HotLogLevel[HotLogLevel["None"] = 5] = "None";
})(HotLogLevel || (exports.HotLogLevel = HotLogLevel = {}));
/**
 * The logger.
 */
class HotLog {
    constructor(logLevel = HotLogLevel.All) {
        this.logLevel = logLevel;
        this.showResponses = false;
        this.showHTTPEvents = false;
        this.showWebSocketEvents = false;
    }
    /**
     * Parse the logging level.
     */
    static parse(logLevel) {
        let level = HotLogLevel.All;
        if (logLevel === "info")
            level = HotLogLevel.Info;
        if (logLevel === "warning")
            level = HotLogLevel.Warning;
        if (logLevel === "error")
            level = HotLogLevel.Error;
        if (logLevel === "verbose")
            level = HotLogLevel.Verbose;
        if (logLevel === "all")
            level = HotLogLevel.All;
        if (logLevel === "none")
            level = HotLogLevel.None;
        return (level);
    }
    /**
     * Log a message.
     */
    log(level, message) {
        if (this.logLevel === HotLogLevel.Verbose) {
            if (level === HotLogLevel.Error)
                this.error(message);
            if (level === HotLogLevel.Warning)
                this.warning(message);
            if ((level === HotLogLevel.Info) ||
                (level === HotLogLevel.Verbose)) {
                this.info(message);
            }
        }
        if (this.logLevel === HotLogLevel.All) {
            if (level === HotLogLevel.Error)
                this.error(message);
            if (level === HotLogLevel.Warning)
                this.warning(message);
            if (level === HotLogLevel.Info)
                this.info(message);
        }
        if (this.logLevel === HotLogLevel.Error) {
            if (level === HotLogLevel.Error)
                this.error(message);
        }
        if (this.logLevel === HotLogLevel.Warning) {
            if (level === HotLogLevel.Warning)
                this.warning(message);
        }
        if (this.logLevel === HotLogLevel.Info) {
            if (level === HotLogLevel.Info)
                this.info(message);
        }
    }
    /**
     * Log a verbose message.
     */
    verbose(message, data = null) {
        if (this.logLevel === HotLogLevel.Verbose) {
            if (typeof (message) === "string")
                console.info(message);
            else
                console.info(message(data));
        }
    }
    /**
     * Log a message.
     */
    info(message) {
        if ((this.logLevel === HotLogLevel.All) ||
            (this.logLevel === HotLogLevel.Verbose) ||
            (this.logLevel === HotLogLevel.Info)) {
            console.info(message);
        }
    }
    /**
     * Log a warning.
     */
    warning(message) {
        if ((this.logLevel === HotLogLevel.All) ||
            (this.logLevel === HotLogLevel.Verbose) ||
            (this.logLevel === HotLogLevel.Warning)) {
            console.warn(message);
        }
    }
    /**
     * Log an error message.
     */
    error(message) {
        if ((this.logLevel === HotLogLevel.All) ||
            (this.logLevel === HotLogLevel.Verbose) ||
            (this.logLevel === HotLogLevel.Error)) {
            let msg = "";
            if (typeof (message) === "string")
                msg = message;
            else {
                if (message.message != null)
                    msg = message.message;
                if (message.stack != null)
                    msg = message.stack;
            }
            console.error(msg);
        }
    }
}
exports.HotLog = HotLog;
//# sourceMappingURL=HotLog.js.map