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

View file

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

View file

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

View file

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