Any stream with an on function will register for error

master
Marc Udoff 2015-11-30 20:25:42 -05:00 committed by Trent Mick
parent f299ac98f2
commit e0e06d3af5
1 changed files with 5 additions and 3 deletions

View File

@ -547,9 +547,6 @@ Logger.prototype.addStream = function addStream(s, defaultLevel) {
if (!s.stream) {
s.stream = fs.createWriteStream(s.path,
{flags: 'a', encoding: 'utf8'});
s.stream.on('error', function (err) {
self.emit('error', err, s);
});
if (!s.closeOnExit) {
s.closeOnExit = true;
}
@ -579,6 +576,11 @@ Logger.prototype.addStream = function addStream(s, defaultLevel) {
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);
delete self.haveNonRawStreams; // reset
}