nativescript
Version:
Command-line interface for building NativeScript projects
33 lines • 1.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.configure = configure;
const constants_1 = require("../../../constants");
function emitAppender(layout, emitter) {
const appender = (loggingEvent) => {
emitter.emit(constants_1.EMIT_APPENDER_EVENT_NAME, {
loggingEvent,
formattedMessage: layout(loggingEvent),
});
};
appender.shutdown = () => {
emitter.removeAllListeners(constants_1.EMIT_APPENDER_EVENT_NAME);
};
return appender;
}
function configure(config, layouts) {
if (!config.emitter) {
throw new Error("Emitter must be passed to emit-appender");
}
if (!config.emitter.emit || typeof config.emitter.emit !== "function") {
throw new Error("The passed emitter must be instance of EventEmitter");
}
// 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 emitAppender(layout, config.emitter);
}
//# sourceMappingURL=emit-appender.js.map
;