Fallback to \n if os.EOL is not defined

This commit is contained in:
Gareth Jones 2012-07-04 09:25:08 +10:00
parent b6ba3bce00
commit 7a02f39921
2 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,8 @@ var layouts = require('../layouts')
, path = require('path')
, fs = require('fs')
, streams = require('../streams')
, os = require('os');
, os = require('os')
, eol = os.EOL || '\n';
/**
* File Appender writing the logs to a text file. Supports rolling of logs by size.
@ -47,7 +48,7 @@ function fileAppender (file, layout, logSize, numBackups) {
});
return function(loggingEvent) {
logFile.write(layout(loggingEvent)+os.EOL, "utf8");
logFile.write(layout(loggingEvent) + eol, "utf8");
};
}

View File

@ -1,5 +1,6 @@
var dateFormat = require('./date_format')
, os = require('os')
, eol = os.EOL || '\n'
, util = require('util')
, replacementRegExp = /%[sdj]/g
, layoutMakers = {
@ -198,7 +199,7 @@ function patternLayout (pattern) {
replacement = formatLogData(loggingEvent.data);
break;
case "n":
replacement = os.EOL;
replacement = eol;
break;
case "p":
replacement = loggingEvent.level.toString();