"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class PiLogger {
    constructor(cat) {
        this.active = true;
        this.category = cat;
    }
    static muteAllLogs() {
        PiLogger.muteAll = true;
    }
    static unmuteAllLogs() {
        PiLogger.muteAll = false;
    }
    static showString(s) {
        PiLogger.filter = s;
    }
    info(o, msg) {
        if (this.active && !PiLogger.muteAll) {
            const type = o ? Object.getPrototypeOf(o).constructor.name : "-";
            this.logToConsole(PiLogger.FgBlue, type + ": " + this.message(msg));
        }
    }
    log(msg) {
        if (this.active && !PiLogger.muteAll) {
            this.logToConsole(PiLogger.FgBlack, this.category + ": " + this.message(msg));
        }
    }
    error(o, msg) {
        const type = o ? Object.getPrototypeOf(o).constructor.name : "-";
        console.log(PiLogger.FgRed, "ERROR: " + type + ": " + this.message(msg));
    }
    mute() {
        this.active = false;
        return this;
    }
    show() {
        this.active = true;
        return this;
    }
    message(msg) {
        return typeof msg === "string" ? msg : msg();
    }
    logToConsole(color, message) {
        if (PiLogger.filter === null) {
            console.log(color, message, PiLogger.FgBlack, "");
        }
        else {
            if (message.includes(PiLogger.filter)) {
                console.log(color, message, PiLogger.FgBlack, "");
            }
        }
    }
    colorMyText() {
        var text = "some text with some {special} formatting on this {keyword} and this {keyword}";
        var splitText = text.split(" ");
        var cssRules = [];
        var styledText = "";
        for (var split of splitText) {
            if (/^\{/.test(split)) {
                cssRules.push(PiLogger.FgBlue);
            }
            else {
                cssRules.push("color:inherit");
            }
            styledText += `%c${split} `;
        }
        console.log(styledText, ...cssRules);
    }
}
exports.PiLogger = PiLogger;
PiLogger.muteAll = true;
PiLogger.FgRed = "\x1b[31m";
PiLogger.FgBlack = "\x1b[30m";
PiLogger.FgBlue = "\x1b[34m";
PiLogger.filter = null;
exports.EVENT_LOG = new PiLogger("EVENT").mute();
exports.RENDER_LOG = new PiLogger("RENDER").mute();
//# sourceMappingURL=PiLogging.js.map