"use strict";
/* istanbul ignore file */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const log_level_1 = require("./log-level");
class LoggerBase {
    constructor() {
        this.minimumLogLevel = log_level_1.LogLevel.Info;
    }
    get isDebugEnabled() {
        return this.minimumLogLevel <= log_level_1.LogLevel.Debug;
    }
    get isInfoEnabled() {
        return this.minimumLogLevel <= log_level_1.LogLevel.Info;
    }
    get isWarnEnabled() {
        return this.minimumLogLevel <= log_level_1.LogLevel.Warn;
    }
    get isErrorEnabled() {
        return this.minimumLogLevel <= log_level_1.LogLevel.Error;
    }
    debug(message) {
        if (this.isDebugEnabled) {
            this.handleDebugMessage(typeof message === "function" ? message() : message);
        }
    }
    debugAsync(message) {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.isDebugEnabled) {
                const msg = yield message();
                this.handleDebugMessage(msg);
            }
        });
    }
    info(message) {
        if (this.isInfoEnabled) {
            this.handleInfoMessage(typeof message === "function" ? message() : message);
        }
    }
    infoAsync(message) {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.isInfoEnabled) {
                const msg = yield message();
                this.handleInfoMessage(msg);
            }
        });
    }
    warn(message) {
        if (this.isWarnEnabled) {
            this.handleWarnMessage(typeof message === "function" ? message() : message);
        }
    }
    warnAsync(message) {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.isWarnEnabled) {
                const msg = yield message();
                this.handleWarnMessage(msg);
            }
        });
    }
    error(message, error) {
        if (this.isErrorEnabled) {
            this.handleErrorMessage(typeof message === "function" ? message() : message, error);
        }
    }
    errorAsync(message, error) {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.isErrorEnabled) {
                const msg = yield message();
                this.handleErrorMessage(msg, error);
            }
        });
    }
    handleDebugMessage(message) {
        //TODO Fire event?
        this.logDebug(message);
    }
    handleInfoMessage(message) {
        //TODO Fire event?
        this.logInfo(message);
    }
    handleWarnMessage(message) {
        //TODO Fire event?
        this.logWarn(message);
    }
    handleErrorMessage(message, error) {
        //TODO Fire event?
        this.logError(message, error);
    }
}
exports.default = LoggerBase;
//# sourceMappingURL=logger-base.js.map