"use strict";
exports.__esModule = true;
exports.MyLogger = void 0;
var Methods = ['log', 'info', 'warn', 'error'];
var MyLogger = (function () {
    function MyLogger() {
        this.beforeFuncs = [];
        this.afterFuncs = [];
    }
    MyLogger.prototype._log = function (level, args) {
        this.beforeFuncs.forEach(function (func) { return func(args); });
        console[Methods[level]].apply(console, args);
        this.afterFuncs.forEach(function (func) { return func(args); });
    };
    MyLogger.prototype.log = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        this._log(0, args);
        return this;
    };
    MyLogger.prototype.info = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        this._log(1, args);
        return this;
    };
    MyLogger.prototype.warn = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        this._log(2, args);
        return this;
    };
    MyLogger.prototype.error = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        this._log(3, args);
        return this;
    };
    MyLogger.prototype.addInterceptor = function (func, isBefore) {
        if (isBefore === void 0) { isBefore = true; }
        if (typeof func !== 'function') {
            return this.error('拦截器不符合规范');
        }
        if (isBefore) {
            this.beforeFuncs.push(func);
            return this;
        }
        this.afterFuncs.push(func);
        return this;
    };
    MyLogger.prototype.addBeforeFunc = function (func) {
        this.addInterceptor(func);
        return this;
    };
    MyLogger.prototype.addAfterFunc = function (func) {
        this.addInterceptor(func, false);
        return this;
    };
    return MyLogger;
}());
exports.MyLogger = MyLogger;
