Allow adding of appenders as objects
Previously, appenders could only be added by specifying the filepath to the appender. This required the appender's path to be specified either relative to the log4js installation, relative to a NODE_PATH token, or absolute. This creates a coupling between the log4js configurer and the log4js installation location, or a coupling between the log4js configurer and the global NODE_PATH. This commit removes the coupling by allowing the loading of appenders to be done relative to the log4js configurer.
This commit is contained in:
@@ -86,6 +86,21 @@ vows.describe('log4js configure').addBatch({
|
||||
assert.isFunction(log4js.appenderMakers['some/other/external']);
|
||||
}
|
||||
},
|
||||
'when appender object loaded via loadAppender': {
|
||||
topic: function() {
|
||||
var testAppender = makeTestAppender(),
|
||||
log4js = sandbox.require('../lib/log4js');
|
||||
|
||||
log4js.loadAppender('some/other/external', testAppender);
|
||||
return log4js;
|
||||
},
|
||||
'should load appender with provided object': function(log4js) {
|
||||
assert.ok(log4js.appenders['some/other/external']);
|
||||
},
|
||||
'should add appender configure function to appenderMakers': function(log4js) {
|
||||
assert.isFunction(log4js.appenderMakers['some/other/external']);
|
||||
}
|
||||
},
|
||||
'when configuration file loaded via LOG4JS_CONFIG environment variable': {
|
||||
topic: function() {
|
||||
process.env.LOG4JS_CONFIG = 'some/path/to/mylog4js.json';
|
||||
|
||||
Reference in New Issue
Block a user