import { __read, __spread } from "tslib";
import { ELogLevel } from "./logLevel";
export var createLoggerInstance = function (parent, parentTags, tags) {
    var tagString = parentTags + tags.map(function (tag) { return "[" + tag + "]"; }).join();
    var createSubLogger = function () {
        var extraTags = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            extraTags[_i] = arguments[_i];
        }
        return createLoggerInstance(parent, tagString, extraTags);
    };
    var createLevelLogger = function (level) { return function () {
        var messages = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            messages[_i] = arguments[_i];
        }
        return parent.log.apply(parent, __spread([level, tagString], messages));
    }; };
    var log = function (level) {
        var messages = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            messages[_i - 1] = arguments[_i];
        }
        return parent.log.apply(parent, __spread([level, tagString], messages));
    };
    return {
        createSubLogger: createSubLogger,
        log: log,
        debug: createLevelLogger(ELogLevel.Debug),
        info: createLevelLogger(ELogLevel.Info),
        warn: createLevelLogger(ELogLevel.Warning),
        error: createLevelLogger(ELogLevel.Error),
        fatal: createLevelLogger(ELogLevel.Fatal),
    };
};
