Merged changes
This commit is contained in:
@@ -13,6 +13,8 @@ var layouts = require('../layouts')
|
||||
function fileAppender (file, layout, logSize, numBackups, filePollInterval) {
|
||||
layout = layout || layouts.basicLayout;
|
||||
numBackups = numBackups === undefined ? 5 : numBackups;
|
||||
//there has to be at least one backup if logSize has been specified
|
||||
numBackups = numBackups === 0 ? 1 : numBackups;
|
||||
filePollInterval = filePollInterval * 1000 || 30000;
|
||||
|
||||
function setupLogRolling () {
|
||||
@@ -31,25 +33,21 @@ function fileAppender (file, layout, logSize, numBackups, filePollInterval) {
|
||||
}
|
||||
|
||||
function rollThatLog () {
|
||||
if (numBackups > 0) {
|
||||
//roll the backups (rename file.n-1 to file.n, where n <= numBackups)
|
||||
for (var i=numBackups; i > 0; i--) {
|
||||
if (i > 1) {
|
||||
if (fileExists(file + '.' + (i-1))) {
|
||||
fs.renameSync(file+'.'+(i-1), file+'.'+i);
|
||||
}
|
||||
} else {
|
||||
fs.renameSync(file, file+'.1');
|
||||
//roll the backups (rename file.n-1 to file.n, where n <= numBackups)
|
||||
for (var i=numBackups; i > 0; i--) {
|
||||
if (i > 1) {
|
||||
if (fileExists(file + '.' + (i-1))) {
|
||||
fs.renameSync(file+'.'+(i-1), file+'.'+i);
|
||||
}
|
||||
} else {
|
||||
fs.renameSync(file, file+'.1');
|
||||
}
|
||||
//let's make a new file
|
||||
var newLogFileFD = fs.openSync(file, 'a', 0644)
|
||||
, oldLogFileFD = logFile.fd;
|
||||
logFile.fd = newLogFileFD;
|
||||
fs.close(oldLogFileFD);
|
||||
} else {
|
||||
fs.truncate(logFile.fd, logSize);
|
||||
}
|
||||
//let's make a new file
|
||||
var newLogFileFD = fs.openSync(file, 'a', 0644)
|
||||
, oldLogFileFD = logFile.fd;
|
||||
logFile.fd = newLogFileFD;
|
||||
fs.close(oldLogFileFD);
|
||||
}
|
||||
|
||||
function fileExists (filename) {
|
||||
|
||||
@@ -159,7 +159,9 @@ function configureLevels(levels) {
|
||||
}
|
||||
} else {
|
||||
for (l in loggers) {
|
||||
loggers[l].setLevel();
|
||||
if (loggers.hasOwnProperty(l)) {
|
||||
loggers[l].setLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -323,7 +325,7 @@ function initReloadConfiguration(filename, options) {
|
||||
function configure (configurationFileOrObject, options) {
|
||||
var config = configurationFileOrObject;
|
||||
if (config === undefined || config === null || typeof(config) === 'string') {
|
||||
options = options || { reloadSecs: 60 };
|
||||
options = options || { };
|
||||
if (options.reloadSecs) {
|
||||
initReloadConfiguration(config, options);
|
||||
}
|
||||
@@ -355,9 +357,11 @@ function replaceConsole(logger) {
|
||||
function loadAppenders() {
|
||||
var appenderList = fs.readdirSync(__dirname + '/appenders');
|
||||
appenderList.forEach(function(file) {
|
||||
var appenderModule = require('./appenders/' + file);
|
||||
module.exports.appenders[appenderModule.name] = appenderModule.appender;
|
||||
appenderMakers[appenderModule.name] = appenderModule.configure;
|
||||
if (/\.js$/.test(file)) {
|
||||
var appenderModule = require('./appenders/' + file);
|
||||
module.exports.appenders[appenderModule.name] = appenderModule.appender;
|
||||
appenderMakers[appenderModule.name] = appenderModule.configure;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user