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