2013-05-25 12:00:06 +08:00
|
|
|
"use strict";
|
|
|
|
var layouts = require('../layouts')
|
2013-07-10 20:07:28 +08:00
|
|
|
, consoleLog = console.log.bind(console);
|
2011-07-24 19:58:02 +08:00
|
|
|
|
2015-03-20 10:51:23 +08:00
|
|
|
function consoleAppender (layout, timezoneOffset) {
|
2013-05-25 12:00:06 +08:00
|
|
|
layout = layout || layouts.colouredLayout;
|
|
|
|
return function(loggingEvent) {
|
2015-03-20 10:51:23 +08:00
|
|
|
consoleLog(layout(loggingEvent, timezoneOffset));
|
2013-05-25 12:00:06 +08:00
|
|
|
};
|
2011-07-24 19:58:02 +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);
|
|
|
|
}
|
2015-03-20 10:51:23 +08:00
|
|
|
return consoleAppender(layout, config.timezoneOffset);
|
2011-07-24 19:58:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.appender = consoleAppender;
|
|
|
|
exports.configure = configure;
|