Re-emit fs.createWriteStream errors

This commit is contained in:
Evan Oxfeld 2012-06-04 23:23:12 -04:00
parent 4f28afc7a2
commit 632379030e
2 changed files with 7 additions and 1 deletions

View file

@ -443,6 +443,7 @@ Supported stream types are:
"level": "warn" "level": "warn"
} }
- Bunyan re-emits error events if the file cannot be opened successfully.
# License # License

View file

@ -25,6 +25,7 @@ var os = require('os');
var fs = require('fs'); var fs = require('fs');
var util = require('util'); var util = require('util');
var assert = require('assert'); var assert = require('assert');
var EventEmitter = require('events').EventEmitter;
@ -169,6 +170,8 @@ function resolveLevel(nameOrNum) {
//---- Logger class //---- Logger class
Logger.prototype = new EventEmitter;
/** /**
* Create a Logger instance. * Create a Logger instance.
* *
@ -316,7 +319,9 @@ function Logger(options, _childOptions, _childSimple) {
case 'file': case 'file':
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'}).on('error', function(err) {
self.emit('error', err);
});
if (!s.closeOnExit) { if (!s.closeOnExit) {
s.closeOnExit = true; s.closeOnExit = true;
} }