use raw stream support
This commit is contained in:
parent
b0daeb6706
commit
b378560eac
5 changed files with 8 additions and 11 deletions
|
@ -476,6 +476,7 @@ To use a RingBuffer:
|
|||
var ringbuffer = new bunyan.RingBuffer({ limit: 100 });
|
||||
var log = new bunyan({
|
||||
name: "foo",
|
||||
raw: true,
|
||||
stream: ringbuffer,
|
||||
level: "debug"
|
||||
});
|
||||
|
@ -487,6 +488,7 @@ This example emits:
|
|||
|
||||
[ { name: 'foo',
|
||||
hostname: '912d2b29',
|
||||
raw: true,
|
||||
pid: 50346,
|
||||
level: 30,
|
||||
msg: 'hello world',
|
||||
|
|
|
@ -212,10 +212,10 @@ function emitNextRecord(opts, stylize)
|
|||
continue;
|
||||
|
||||
if (streams[ofile].records.length > 0) {
|
||||
if (!streams[ofile].paused) {
|
||||
if (!streams[ofile].paused) {
|
||||
streams[ofile].paused = true;
|
||||
streams[ofile].stream.pause();
|
||||
}
|
||||
}
|
||||
} else if (streams[ofile].paused) {
|
||||
streams[ofile].paused = false;
|
||||
streams[ofile].stream.resume();
|
||||
|
|
|
@ -3,6 +3,7 @@ var bunyan = require('..');
|
|||
var ringbuffer = new bunyan.RingBuffer({ limit: 100 });
|
||||
var log = new bunyan({
|
||||
name: 'foo',
|
||||
raw: true,
|
||||
stream: ringbuffer,
|
||||
level: 'debug'
|
||||
});
|
||||
|
|
|
@ -992,18 +992,11 @@ function RingBuffer(options) {
|
|||
|
||||
util.inherits(RingBuffer, EventEmitter);
|
||||
|
||||
RingBuffer.prototype.write = function (str) {
|
||||
var json;
|
||||
|
||||
RingBuffer.prototype.write = function (record) {
|
||||
if (!this.writable)
|
||||
throw (new Error('RingBuffer has been ended already'));
|
||||
|
||||
try {
|
||||
json = JSON.parse(str);
|
||||
this.entries.push(json);
|
||||
} catch (ex) {
|
||||
this.entries.push(str);
|
||||
}
|
||||
this.entries.push(record);
|
||||
|
||||
if (this.entries.length > this.limit)
|
||||
this.entries.shift();
|
||||
|
|
|
@ -11,6 +11,7 @@ var log1 = new Logger({
|
|||
streams: [
|
||||
{
|
||||
stream: ringbuffer,
|
||||
raw: true,
|
||||
level: 'info'
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue