var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Log = void 0;
var CC = require("@meesvdw/coloredconsole");
function Log(level) {
    var args = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        args[_i - 1] = arguments[_i];
    }
    if (level.includes('.js')) {
        level = args[0];
        args.splice(0, 1);
    }
    function log(origin) {
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        level = level.toLowerCase().replace('warning', 'warn');
        var format;
        if (level == 'info')
            format = CC.BG.black + CC.white + '  INFO  ';
        else if (level == 'error')
            format = CC.BG.black + CC.red + '  ERROR ';
        else if (level == 'warn')
            format = CC.BG.black + CC.yellow + '  WARN  ';
        else if (level == 'crit')
            format = CC.BG.red + CC.black + '  CRIT  ';
        if (origin == 'Core' && level != 'crit')
            origin = CC.green + origin + CC.white;
        var d = new Date();
        var n = d.toLocaleTimeString();
        format = "".concat(format, " ").concat(n, "  ").concat(origin, "   ").concat(args, " ").concat(CC.reset);
        console.log(format);
    }
    var error = new Error();
    if (error && error.stack) {
        var stackArray = error.stack.replace('Error\n', '').replace(/ at /g, '%*%').replace(/ /g, '').split('%*%');
        stackArray.splice(0, 1);
        if (stackArray.length > 1) {
            var callerSplit = stackArray[1].replace(/\\/g, '/').split('/');
            var caller = callerSplit[callerSplit.length - 1].replace(/\n/g, '').replace(')', '');
            return log.apply(void 0, __spreadArray([caller], args, false));
        }
    }
    log.apply(void 0, __spreadArray(['Unknown'], args, false));
}
exports.Log = Log;
//# sourceMappingURL=Logger.js.map