From 0c28041f6d62d515f5cda870c5ac450ff4a9fba1 Mon Sep 17 00:00:00 2001 From: compulim Date: Thu, 11 Sep 2014 12:15:04 +0800 Subject: [PATCH] Flush buffer again after first "flush" event --- lib/winston/transports/file.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index 47bbee56f..6797580ad 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -441,6 +441,11 @@ File.prototype._createStream = function () { // and thus can emit the `open` event. // self.once('flush', function () { + // Because "flush" event is based on native stream "drain" event, + // logs could be written inbetween "self.flush()" and here + // Therefore, we need to flush again to make sure everything is flushed + self.flush(); + self.opening = false; self.emit('open', fullname); });