Skip to content

Commit

Permalink
core: use host OS specific line endings
Browse files Browse the repository at this point in the history
Rather than just forcing LF line endings everywhere, allow for CR/LF
when running on Windows.

Signed-off-by: Ryan Graham <[email protected]>
  • Loading branch information
rmg committed Dec 12, 2018
1 parent 907a21f commit 71af900
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

'use strict';

var os = require('os');
var util = require('util');

var StringDecoder = require('string_decoder').StringDecoder;
Expand Down Expand Up @@ -104,7 +105,7 @@ function reLiner() {

function appendNewline(line, _enc, callback) {
this.push(line);
callback(null, Buffer.from('\n'));
callback(null, Buffer.from(os.EOL));
}
}

Expand Down Expand Up @@ -143,7 +144,7 @@ function textFormatter(options) {
if (options.timeStamp) {
line = util.format('%s %s', new Date(logEvent.time).toISOString(), line);
}
callback(null, line.replace(/\n/g, '\\n'));
callback(null, line.replace(/\r?\n/g, '\\n'));
}

function textifyTags(tags) {
Expand Down Expand Up @@ -190,7 +191,7 @@ function lineMerger(host) {
function lineMergerWrite(line, _enc, callback) {
if (/^\s+/.test(line.msg)) {
if (previousLine) {
previousLine.msg += '\n' + line.msg;
previousLine.msg += os.EOL + line.msg;
} else {
previousLine = line;
}
Expand Down

0 comments on commit 71af900

Please sign in to comment.