2013-06-04 06:17:36 +08:00
|
|
|
"use strict";
|
|
|
|
var levels = require('../levels')
|
|
|
|
, log4js = require('../log4js');
|
2011-07-24 19:58:02 +08:00
|
|
|
|
|
|
|
function logLevelFilter (levelString, appender) {
|
2013-06-04 06:17:36 +08:00
|
|
|
var level = levels.toLevel(levelString);
|
|
|
|
return function(logEvent) {
|
|
|
|
if (logEvent.level.isGreaterThanOrEqualTo(level)) {
|
|
|
|
appender(logEvent);
|
2011-07-24 19:58:02 +08:00
|
|
|
}
|
2013-06-04 06:17:36 +08:00
|
|
|
};
|
2011-07-24 19:58:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function configure(config) {
|
2013-06-04 06:17:36 +08:00
|
|
|
log4js.loadAppender(config.appender.type);
|
|
|
|
var appender = log4js.appenderMakers[config.appender.type](config.appender);
|
|
|
|
return logLevelFilter(config.level, appender);
|
2011-07-24 19:58:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.appender = logLevelFilter;
|
2011-10-27 13:37:11 +08:00
|
|
|
exports.configure = configure;
|