mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
fixes: premature close, file handles, raw streams → stderr
- premature close: don't close the ringBuffer until we're done logging - file handles: calling child.reopenFileStreams() invalidates the fd - raw streams → stderr: app dies the moment bunyan pushes a raw log to stderr
This commit is contained in:
@@ -5,9 +5,6 @@ let ringBufferOptions: Logger.RingBufferOptions = {
|
||||
};
|
||||
let ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions);
|
||||
ringBuffer.write("hello");
|
||||
ringBuffer.end();
|
||||
ringBuffer.destroy();
|
||||
ringBuffer.destroySoon();
|
||||
|
||||
let level: number;
|
||||
level = Logger.resolveLevel("trace");
|
||||
@@ -46,7 +43,7 @@ let options: Logger.LoggerOptions = {
|
||||
}, {
|
||||
type: 'raw',
|
||||
stream: process.stderr,
|
||||
level: Logger.WARN
|
||||
level: Logger.FATAL + 1, // disabled, as stderr explodes when given raw streams
|
||||
}, {
|
||||
type: 'raw',
|
||||
stream: ringBuffer,
|
||||
@@ -78,16 +75,6 @@ log.levels(0, Logger.INFO);
|
||||
log.levels(0, 'info');
|
||||
log.levels('foo', Logger.WARN);
|
||||
|
||||
let child = log.child({ name: 'child' });
|
||||
child.reopenFileStreams();
|
||||
log.addStream({ path: '/dev/null' });
|
||||
child.level(Logger.DEBUG);
|
||||
child.level('debug');
|
||||
child.levels(0, Logger.ERROR);
|
||||
child.levels(0, 'error');
|
||||
child.levels('stream1', Logger.FATAL);
|
||||
child.levels('stream1', 'fatal');
|
||||
|
||||
let buffer = new Buffer(0);
|
||||
let error = new Error('');
|
||||
let object = {
|
||||
@@ -138,3 +125,17 @@ class MyLogger extends Logger {
|
||||
super(options);
|
||||
}
|
||||
}
|
||||
|
||||
let child = log.child({ widget_type: 'wuzzle' });
|
||||
child.reopenFileStreams();
|
||||
log.addStream({ path: '/dev/null' });
|
||||
child.level(Logger.DEBUG);
|
||||
child.level('debug');
|
||||
child.levels(0, Logger.ERROR);
|
||||
child.levels(0, 'error');
|
||||
child.levels('foo', Logger.FATAL);
|
||||
child.levels('foo', 'fatal');
|
||||
|
||||
ringBuffer.end();
|
||||
ringBuffer.destroy();
|
||||
ringBuffer.destroySoon();
|
||||
|
||||
Reference in New Issue
Block a user