feature: allow passing cwd as an option

This commit is contained in:
Shripad K 2012-02-07 12:41:10 +05:30
parent 2ab6f5fa24
commit b4ca201a91

View File

@ -324,14 +324,20 @@ function initReloadConfiguration(filename, options) {
function configure (configurationFileOrObject, options) { function configure (configurationFileOrObject, options) {
var config = configurationFileOrObject; 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 (config === undefined || config === null || typeof(config) === 'string') {
options = options || { };
if (options.reloadSecs) { if (options.reloadSecs) {
initReloadConfiguration(config, options); initReloadConfiguration(config, options);
} }
configureOnceOff(loadConfigurationFile(config)); configureOnceOff(loadConfigurationFile(config));
} else { } else {
options = options || {};
if (options.reloadSecs) { if (options.reloadSecs) {
getLogger('log4js').warn('Ignoring configuration reload parameter for "object" configuration.'); getLogger('log4js').warn('Ignoring configuration reload parameter for "object" configuration.');
} }