"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configure = configure;
const constants_1 = require("../../../constants");
function cliAppender(layout) {
    const appender = (loggingEvent) => {
        if (loggingEvent && loggingEvent.data) {
            const stream = loggingEvent.context[constants_1.LoggerConfigData.useStderr]
                ? process.stderr
                : process.stdout;
            const preparedData = layout(loggingEvent);
            stream.write(preparedData);
        }
    };
    return appender;
}
function configure(config, layouts) {
    let layout = layouts.messagePassThroughLayout;
    if (config.layout) {
        layout = layouts.layout(config.layout.type, config.layout);
    }
    return cliAppender(layout);
}
