use raw stream support

This commit is contained in:
Dave Pacheco 2012-06-20 16:26:28 -07:00
parent b0daeb6706
commit b378560eac
5 changed files with 8 additions and 11 deletions

View file

@ -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',

View file

@ -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'
}); });

View file

@ -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();

View file

@ -11,6 +11,7 @@ var log1 = new Logger({
streams: [ streams: [
{ {
stream: ringbuffer, stream: ringbuffer,
raw: true,
level: 'info' level: 'info'
} }
] ]