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);