|
|
|
@ -1,12 +1,17 @@
|
|
|
|
|
var layouts = require('../layouts')
|
|
|
|
|
, path = require('path')
|
|
|
|
|
, fs = require('fs')
|
|
|
|
|
, streams = require('../streams')
|
|
|
|
|
, os = require('os')
|
|
|
|
|
, eol = os.EOL || '\n';
|
|
|
|
|
, path = require('path')
|
|
|
|
|
, fs = require('fs')
|
|
|
|
|
, streams = require('../streams')
|
|
|
|
|
, os = require('os')
|
|
|
|
|
, eol = os.EOL || '\n'
|
|
|
|
|
, openFiles = [];
|
|
|
|
|
|
|
|
|
|
var openFiles = [];
|
|
|
|
|
var listenerAtttached = false;
|
|
|
|
|
//close open files on process exit.
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
|
openFiles.forEach(function (file) {
|
|
|
|
|
file.end();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* File Appender writing the logs to a text file. Supports rolling of logs by size.
|
|
|
|
@ -48,16 +53,6 @@ function fileAppender (file, layout, logSize, numBackups) {
|
|
|
|
|
// push file to the stack of open handlers
|
|
|
|
|
openFiles.push(logFile);
|
|
|
|
|
|
|
|
|
|
//close the file on process exit.
|
|
|
|
|
if (!listenerAtttached) {
|
|
|
|
|
listenerAtttached = true;
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
|
openFiles.forEach(function (file) {
|
|
|
|
|
file.end();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function(loggingEvent) {
|
|
|
|
|
logFile.write(layout(loggingEvent) + eol, "utf8");
|
|
|
|
|
};
|
|
|
|
|