From 2632eb8af24e042edcfa354fdc670751df30652c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20F=2E=20Romaniello?= Date: Tue, 9 Dec 2014 10:22:39 -0300 Subject: [PATCH] add option for EOL chars on FileTransport --- docs/transports.md | 1 + lib/winston/transports/file.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/transports.md b/docs/transports.md index 2737efc70..ab2b205e6 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -66,6 +66,7 @@ The File transport should really be the 'Stream' transport since it will accept * __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded. * __stream:__ The WriteableStream to write output to. * __json:__ If true, messages will be logged as JSON (default true). +* __eol:__ string indicating the end-of-live characters to use (default to `\n`). *Metadata:* Logged via util.inspect(meta); diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index add027dba..d4ab73575 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -74,6 +74,7 @@ var File = exports.File = function (options) { this.prettyPrint = options.prettyPrint || false; this.label = options.label || null; this.timestamp = options.timestamp != null ? options.timestamp : true; + this.eol = options.eol || '\n'; if (this.json) { this.stringify = options.stringify; @@ -130,7 +131,7 @@ File.prototype.log = function (level, msg, meta, callback) { timestamp: this.timestamp, stringify: this.stringify, label: this.label - }) + '\n'; + }) + this.eol; this._size += output.length;