Skip to content

Commit

Permalink
fix(lib): File Transports Not Emitting Errors On Stream Errors
Browse files Browse the repository at this point in the history
In this commit file & daily-rotate-file add an 'error' event listener on
their stream so that we can emit those errors from the transport.

fixes #511
  • Loading branch information
Alex Bell authored and indexzero committed Apr 7, 2015
1 parent b85201f commit 4efdf87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/winston/transports/daily-rotate-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ var DailyRotateFile = exports.DailyRotateFile = function (options) {
else if (options.stream) {
throwIf('stream', 'filename', 'maxsize');
this._stream = options.stream;
this._stream.on('error', function(error){
self.emit('error', error);
});

//
// We need to listen for drain events when
Expand Down Expand Up @@ -464,6 +467,9 @@ DailyRotateFile.prototype._createStream = function () {
self._size = size;
self.filename = target;
self._stream = fs.createWriteStream(fullname, self.options);
self._stream.on('error', function(error){
self.emit('error', error);
});

//
// We need to listen for drain events when
Expand Down
6 changes: 6 additions & 0 deletions lib/winston/transports/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ var File = exports.File = function (options) {
throwIf('stream', 'filename', 'maxsize');
this._stream = options.stream;
this._isStreams2 = isWritable(this._stream);
this._stream.on('error', function(error){
self.emit('error', error);
});
//
// We need to listen for drain events when
// write() returns false. This can make node
Expand Down Expand Up @@ -452,6 +455,9 @@ File.prototype._createStream = function () {
self.filename = target;
self._stream = fs.createWriteStream(fullname, self.options);
self._isStreams2 = isWritable(self._stream);
self._stream.on('error', function(error){
self.emit('error', error);
});
//
// We need to listen for drain events when
// write() returns false. This can make node
Expand Down

0 comments on commit 4efdf87

Please sign in to comment.