More fixes + Test for "cwd" option
This commit is contained in:
@@ -325,24 +325,36 @@ function initReloadConfiguration(filename, options) {
|
||||
function configure (configurationFileOrObject, options) {
|
||||
var config = configurationFileOrObject;
|
||||
options = options || {};
|
||||
if (options.hasOwnProperty('cwd')) {
|
||||
config.appenders.forEach(function(appender) {
|
||||
if (appender.hasOwnProperty('filename')) {
|
||||
appender.filename = options.cwd + '/' + appender.filename;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (config === undefined || config === null || typeof(config) === 'string') {
|
||||
if (options.reloadSecs) {
|
||||
initReloadConfiguration(config, options);
|
||||
}
|
||||
configureOnceOff(loadConfigurationFile(config));
|
||||
config = loadConfigurationFile(config);
|
||||
} else {
|
||||
if (options.reloadSecs) {
|
||||
getLogger('log4js').warn('Ignoring configuration reload parameter for "object" configuration.');
|
||||
}
|
||||
configureOnceOff(config);
|
||||
}
|
||||
|
||||
if (options.hasOwnProperty('cwd')) {
|
||||
if(config.hasOwnProperty('appenders')) {
|
||||
config.appenders.forEach(function(appender) {
|
||||
if (!appender.hasOwnProperty('type')) return;
|
||||
|
||||
if (appender.type === 'file') {
|
||||
if(!appender.hasOwnProperty('filename')) return;
|
||||
if(appender.hasOwnProperty('absolute')) {
|
||||
if(appender.absolute) return;
|
||||
}
|
||||
|
||||
appender.filename = path.join(options.cwd, appender.filename);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
configureOnceOff(config);
|
||||
}
|
||||
|
||||
function replaceConsole(logger) {
|
||||
|
||||
Reference in New Issue
Block a user