Adjusting and adding new tests for logLevelFilter to handle the maxLevel option.

cdb
Jakub Chmura 10 years ago
parent 00c62c7fa6
commit ade6dd8ea0

@ -22,6 +22,7 @@ vows.describe('log4js logLevelFilter').addBatch({
require('../lib/appenders/logLevelFilter')
.appender(
'ERROR',
undefined,
function(evt) { logEvents.push(evt); }
),
"logLevelTest"
@ -48,13 +49,16 @@ vows.describe('log4js logLevelFilter').addBatch({
remove(__dirname + '/logLevelFilter.log');
remove(__dirname + '/logLevelFilter-warnings.log');
remove(__dirname + '/logLevelFilter-debugs.log');
log4js.configure('test/with-logLevelFilter.json');
logger = log4js.getLogger("tests");
logger.info('main');
logger.error('both');
logger.warn('both');
logger.debug('main');
logger.debug('debug');
logger.info('info');
logger.error('error');
logger.warn('warn');
logger.debug('debug');
logger.trace('trace');
//wait for the file system to catch up
setTimeout(this.callback, 500);
},
@ -64,7 +68,7 @@ vows.describe('log4js logLevelFilter').addBatch({
},
'should contain all log messages': function (contents) {
var messages = contents.trim().split(EOL);
assert.deepEqual(messages, ['main','both','both','main']);
assert.deepEqual(messages, ['debug','info','error','warn','debug','trace']);
}
},
'tmp-tests-warnings.log': {
@ -73,7 +77,16 @@ vows.describe('log4js logLevelFilter').addBatch({
},
'should contain only error and warning log messages': function(contents) {
var messages = contents.trim().split(EOL);
assert.deepEqual(messages, ['both','both']);
assert.deepEqual(messages, ['error','warn']);
}
},
'tmp-tests-debugs.log': {
topic: function() {
fs.readFile(__dirname + '/logLevelFilter-debugs.log','utf8',this.callback);
},
'should contain only trace and debug log messages': function(contents) {
var messages = contents.trim().split(EOL);
assert.deepEqual(messages, ['debug','debug','trace']);
}
}
}

@ -12,6 +12,19 @@
}
}
},
{
"category": "tests",
"type": "logLevelFilter",
"level": "TRACE",
"maxLevel": "DEBUG",
"appender": {
"type": "file",
"filename": "test/logLevelFilter-debugs.log",
"layout": {
"type": "messagePassThrough"
}
}
},
{
"category": "tests",
"type": "file",
@ -23,6 +36,6 @@
],
"levels": {
"tests": "DEBUG"
"tests": "TRACE"
}
}

Loading…
Cancel
Save