Any stream with an on function will register for error

This commit is contained in:
Marc Udoff 2015-11-30 20:25:42 -05:00 committed by Trent Mick
parent f299ac98f2
commit e0e06d3af5

View file

@ -547,9 +547,6 @@ Logger.prototype.addStream = function addStream(s, defaultLevel) {
if (!s.stream) { if (!s.stream) {
s.stream = fs.createWriteStream(s.path, s.stream = fs.createWriteStream(s.path,
{flags: 'a', encoding: 'utf8'}); {flags: 'a', encoding: 'utf8'});
s.stream.on('error', function (err) {
self.emit('error', err, s);
});
if (!s.closeOnExit) { if (!s.closeOnExit) {
s.closeOnExit = true; s.closeOnExit = true;
} }
@ -579,6 +576,11 @@ Logger.prototype.addStream = function addStream(s, defaultLevel) {
throw new TypeError('unknown stream type "' + s.type + '"'); throw new TypeError('unknown stream type "' + s.type + '"');
} }
if(typeof s.stream.on === 'function') {
s.stream.on('error', function (err) {
self.emit('error', err, s);
});
}
self.streams.push(s); self.streams.push(s);
delete self.haveNonRawStreams; // reset delete self.haveNonRawStreams; // reset
} }