Merge pull request #21 from EvanOxfeld/reemit-createWriteStream-errors
Re-emit fs.createWriteStream errors
This commit is contained in:
commit
63711a654a
2 changed files with 7 additions and 1 deletions
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue