Add unit test to check if the level is set on all categories
This commit is contained in:
parent
6ae01b2b84
commit
8cf03507dd
@ -81,6 +81,41 @@ vows.describe('log4js global loglevel').addBatch({
|
||||
log2.removeLevel();
|
||||
assert.equal(log1.level.toString(), oldLevel);
|
||||
assert.equal(log2.level.toString(), oldLevel);
|
||||
},
|
||||
|
||||
'set level on all categories': function(log4js) {
|
||||
// Get 2 loggers
|
||||
var log1 = log4js.getLogger('log1');
|
||||
var log2 = log4js.getLogger('log2');
|
||||
|
||||
// First a test with 2 categories with different levels
|
||||
var config = {
|
||||
'levels': {
|
||||
'log1': 'ERROR',
|
||||
'log2': 'WARN'
|
||||
}
|
||||
};
|
||||
log4js.configure(config);
|
||||
|
||||
// Check if the levels are set correctly
|
||||
assert.equal('ERROR', log1.level.toString());
|
||||
assert.equal('WARN', log2.level.toString());
|
||||
|
||||
log1.removeLevel();
|
||||
log2.removeLevel();
|
||||
|
||||
// Almost identical test, but now we set
|
||||
// level on all categories
|
||||
var config2 = {
|
||||
'levels': {
|
||||
'[all]': 'DEBUG'
|
||||
}
|
||||
};
|
||||
log4js.configure(config2);
|
||||
|
||||
// Check if the loggers got the DEBUG level
|
||||
assert.equal('DEBUG', log1.level.toString());
|
||||
assert.equal('DEBUG', log2.level.toString());
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
|
Loading…
Reference in New Issue
Block a user