"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.layout = void 0;
const util_1 = require("util");
const helpers_1 = require("../../helpers");
const constants_1 = require("../../../constants");
const os_1 = require("os");
const color_1 = require("../../../color");
function layout(config) {
    return function (logEvent) {
        let msg = util_1.format.apply(null, logEvent.data);
        if (logEvent.context[constants_1.LoggerConfigData.wrapMessageWithBorders]) {
            msg = (0, helpers_1.getMessageWithBorders)(msg);
        }
        if (!logEvent.context[constants_1.LoggerConfigData.skipNewLine]) {
            msg += os_1.EOL;
        }
        if (logEvent.level.isEqualTo(constants_1.LoggerLevel.INFO)) {
            return msg;
        }
        if (logEvent.level.isEqualTo(constants_1.LoggerLevel.ERROR)) {
            return color_1.color.red.bold(msg);
        }
        if (logEvent.level.isEqualTo(constants_1.LoggerLevel.WARN)) {
            return color_1.color.yellow(msg);
        }
        if (logEvent.level.isEqualTo(constants_1.LoggerLevel.TRACE)) {
            return color_1.color.grey(msg);
        }
        return msg;
    };
}
exports.layout = layout;
