"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cast_de_nrw_schule_svws_logger_Logger = exports.Logger = void 0;
const JavaObject_1 = require("../java/lang/JavaObject");
const LogData_1 = require("../logger/LogData");
const Vector_1 = require("../java/util/Vector");
const LogLevel_1 = require("../logger/LogLevel");
class Logger extends JavaObject_1.JavaObject {
    consumer = new Vector_1.Vector();
    defaultLevel = LogLevel_1.LogLevel.INFO;
    indent = 0;
    constructor() {
        super();
    }
    /**
     * Fügt einen Consumer für Log-Informationen zum Logger hinzu.
     *
     * @param c   der hinzuzufügende Consumer von Log-Informationen
     */
    addConsumer(c) {
        this.consumer.add(c);
    }
    /**
     * Fügt alle Consumer des anderen Loggers zu diesem hinzu.
     *
     * @param other   der andere Logger
     */
    copyConsumer(other) {
        this.consumer.addAll(other.consumer);
    }
    /**
     * Entfernt den angegeben Consumer für Log-Informationen aus dem Logger.
     *
     * @param c   der zu entfernende Consumer von Log-Informationen
     */
    removeConsumer(c) {
        this.consumer.remove(c);
    }
    /**
     * Gibt das aktuelle Default-Log-Level für neue Log-Informationen zurück.
     *
     * @return das aktuelle Default-Log-Level für neue Log-Informationen
     */
    getDefaultLevel() {
        return this.defaultLevel;
    }
    /**
     * Setzt das Default-Log-Level für neue Log-Informationen.
     *
     * @param defaultLevel   das neue Default-Log-Level für neue Log-Informationen
     */
    setDefaultLevel(defaultLevel) {
        this.defaultLevel = defaultLevel;
    }
    /**
     * Setzt die Anzahl der Leerzeichen, die für die Einrückung bei einer Ausgabe von
     * neuen Log-Informationen genutzt wird.
     *
     * @param indent   die Anzahl der Leerzeichen
     */
    setIndent(indent) {
        this.indent = (indent < 0) ? 0 : indent;
    }
    /**
     * Verändert die Anzahl der Leerzeichen, die für die Einrückung bei einer Ausgabe von
     * neuen Log-Informationen genutzt wird.
     *
     * @param indent   die Veränderung bei der Anzahl der Leerzeichen
     */
    modifyIndent(indent) {
        this.indent = (this.indent + indent < 0) ? 0 : this.indent + indent;
    }
    /**
     * Implementation for method overloads of 'log'
     */
    log(__param0, __param1, __param2) {
        if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.logger.LogData')))) && (typeof __param1 === "undefined") && (typeof __param2 === "undefined")) {
            let data = (0, LogData_1.cast_de_nrw_schule_svws_logger_LogData)(__param0);
            for (let i = 0; i < this.consumer.size(); i++) {
                let c = this.consumer.get(i);
                if (c === null)
                    continue;
                c.accept(data);
            }
        }
        else if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.logger.LogLevel')))) && ((typeof __param1 !== "undefined") && typeof __param1 === "number") && ((typeof __param2 !== "undefined") && ((__param2 instanceof String) || (typeof __param2 === "string")))) {
            let level = (0, LogLevel_1.cast_de_nrw_schule_svws_logger_LogLevel)(__param0);
            let indent = __param1;
            let text = __param2;
            this.log(new LogData_1.LogData(level, indent, false, text));
        }
        else if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.logger.LogLevel')))) && ((typeof __param1 !== "undefined") && ((__param1 instanceof String) || (typeof __param1 === "string"))) && (typeof __param2 === "undefined")) {
            let level = (0, LogLevel_1.cast_de_nrw_schule_svws_logger_LogLevel)(__param0);
            let text = __param1;
            this.log(level, this.indent, text);
        }
        else if (((typeof __param0 !== "undefined") && typeof __param0 === "number") && ((typeof __param1 !== "undefined") && ((__param1 instanceof String) || (typeof __param1 === "string"))) && (typeof __param2 === "undefined")) {
            let indent = __param0;
            let text = __param1;
            this.log(this.defaultLevel, indent, text);
        }
        else if (((typeof __param0 !== "undefined") && ((__param0 instanceof String) || (typeof __param0 === "string"))) && (typeof __param1 === "undefined") && (typeof __param2 === "undefined")) {
            let text = __param0;
            this.log(this.defaultLevel, text);
        }
        else
            throw new Error('invalid method overload');
    }
    /**
     * Implementation for method overloads of 'logLn'
     */
    logLn(__param0, __param1, __param2) {
        if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.logger.LogLevel')))) && ((typeof __param1 !== "undefined") && typeof __param1 === "number") && ((typeof __param2 !== "undefined") && ((__param2 instanceof String) || (typeof __param2 === "string")))) {
            let level = (0, LogLevel_1.cast_de_nrw_schule_svws_logger_LogLevel)(__param0);
            let indent = __param1;
            let text = __param2;
            this.log(new LogData_1.LogData(level, indent, true, text));
        }
        else if (((typeof __param0 !== "undefined") && ((__param0 instanceof JavaObject_1.JavaObject) && (__param0.isTranspiledInstanceOf('de.nrw.schule.svws.logger.LogLevel')))) && ((typeof __param1 !== "undefined") && ((__param1 instanceof String) || (typeof __param1 === "string"))) && (typeof __param2 === "undefined")) {
            let level = (0, LogLevel_1.cast_de_nrw_schule_svws_logger_LogLevel)(__param0);
            let text = __param1;
            this.logLn(level, this.indent, text);
        }
        else if (((typeof __param0 !== "undefined") && typeof __param0 === "number") && ((typeof __param1 !== "undefined") && ((__param1 instanceof String) || (typeof __param1 === "string"))) && (typeof __param2 === "undefined")) {
            let indent = __param0;
            let text = __param1;
            this.logLn(this.defaultLevel, indent, text);
        }
        else if (((typeof __param0 !== "undefined") && ((__param0 instanceof String) || (typeof __param0 === "string"))) && (typeof __param1 === "undefined") && (typeof __param2 === "undefined")) {
            let text = __param0;
            this.logLn(this.defaultLevel, text);
        }
        else
            throw new Error('invalid method overload');
    }
    isTranspiledInstanceOf(name) {
        return ['de.nrw.schule.svws.logger.Logger'].includes(name);
    }
}
exports.Logger = Logger;
function cast_de_nrw_schule_svws_logger_Logger(obj) {
    return obj;
}
exports.cast_de_nrw_schule_svws_logger_Logger = cast_de_nrw_schule_svws_logger_Logger;
//# sourceMappingURL=Logger.js.map