log4js-node/lib/appenders/console.js

22 lines
547 B
JavaScript
Raw Normal View History

2013-05-25 12:00:06 +08:00
"use strict";
var layouts = require('../layouts')
, consoleLog = console.log.bind(console);
function consoleAppender (layout, timezoneOffset) {
2013-05-25 12:00:06 +08:00
layout = layout || layouts.colouredLayout;
return function(loggingEvent) {
consoleLog(layout(loggingEvent, timezoneOffset));
2013-05-25 12:00:06 +08:00
};
}
function configure(config) {
2013-05-25 12:00:06 +08:00
var layout;
if (config.layout) {
layout = layouts.layout(config.layout.type, config.layout);
}
return consoleAppender(layout, config.timezoneOffset);
}
exports.appender = consoleAppender;
exports.configure = configure;