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