"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configure = void 0;
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) {
    // the default layout for the appender
    let layout = layouts.messagePassThroughLayout;
    // check if there is another layout specified
    if (config.layout) {
        layout = layouts.layout(config.layout.type, config.layout);
    }
    // create a new appender instance
    return cliAppender(layout);
}
exports.configure = configure;
//# sourceMappingURL=cli-appender.js.map