From b0227b6c27cf651ffa8b8192ef79ab24296362e3 Mon Sep 17 00:00:00 2001 From: indexzero Date: Tue, 4 Nov 2014 13:56:54 -0500 Subject: [PATCH] [fix] Partial fix for #296. Need to properly detect `_isStreams2` cc/ @jcruggz. --- lib/winston/transports/file.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index c916f7bd3..6a26bc8f3 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -166,6 +166,13 @@ File.prototype.log = function (level, msg, meta, callback) { // Write to the stream, ensure execution of a callback on completion. // File.prototype._write = function(data, callback) { + if (this._isStreams2) { + this._stream.write(data); + return process.nextTick(function () { + callback(null, true); + }); + } + // If this is a file write stream, we could use the builtin // callback functionality, however, the stream is not guaranteed // to be an fs.WriteStream. @@ -295,11 +302,11 @@ File.prototype.stream = function (options) { }; stream.destroy = common.tailFile(tail, function (err, line) { - + if(err){ return stream.emit('error',err); } - + try { stream.emit('data', line); line = JSON.parse(line);