use RingBuffer.records instead of RingBuffer.enties (related to pull #15)

master
Trent Mick 2012-06-21 14:53:05 -07:00
parent 37a1447f22
commit 1eed1fac19
5 changed files with 21 additions and 21 deletions

View File

@ -29,7 +29,7 @@
});
log.info('hello world');
console.log(ringbuffer.entries);
console.log(ringbuffer.records);
- Add support for "raw" streams. This is a logging stream that is given
raw log record objects instead of a JSON-stringified string.

View File

@ -481,7 +481,7 @@ own HTTP interface, or a post-mortem facility like MDB or node-panic.
To use a RingBuffer:
/* Create a ring buffer that stores the last 100 entries. */
/* Create a ring buffer that stores the last 100 records. */
var bunyan = require('bunyan');
var ringbuffer = new bunyan.RingBuffer({ limit: 100 });
var log = new bunyan({
@ -500,7 +500,7 @@ To use a RingBuffer:
});
log.info('hello world');
console.log(ringbuffer.entries);
console.log(ringbuffer.records);
This example emits:

View File

@ -1,4 +1,4 @@
/* Create a ring buffer that stores the last 100 entries. */
/* Create a ring buffer that stores the last 100 records. */
var bunyan = require('..');
var ringbuffer = new bunyan.RingBuffer({ limit: 100 });
var log = new bunyan({
@ -11,4 +11,4 @@ var log = new bunyan({
});
log.info('hello world');
console.log(ringbuffer.entries);
console.log(ringbuffer.records);

View File

@ -982,17 +982,17 @@ var errSerializer = Logger.stdSerializers.err = function err(err) {
/**
* RingBuffer is a Writable Stream that just stores the last N entries in
* RingBuffer is a Writable Stream that just stores the last N records in
* memory.
*
* @param options {Object}, with the following fields:
*
* - limit: number of entries to keep in memory
* - limit: number of records to keep in memory
*/
function RingBuffer(options) {
this.limit = options && options.limit ? options.limit : 100;
this.writable = true;
this.entries = [];
this.records = [];
EventEmitter.call(this);
}
@ -1002,10 +1002,10 @@ RingBuffer.prototype.write = function (record) {
if (!this.writable)
throw (new Error('RingBuffer has been ended already'));
this.entries.push(record);
this.records.push(record);
if (this.entries.length > this.limit)
this.entries.shift();
if (this.records.length > this.limit)
this.records.shift();
return (true);
};

View File

@ -21,19 +21,19 @@ test('ringbuffer', function (t) {
log1.info('hello');
log1.trace('there');
log1.error('android');
t.equal(ringbuffer.entries.length, 2);
t.equal(ringbuffer.entries[0]['msg'], 'hello');
t.equal(ringbuffer.entries[1]['msg'], 'android');
t.equal(ringbuffer.records.length, 2);
t.equal(ringbuffer.records[0]['msg'], 'hello');
t.equal(ringbuffer.records[1]['msg'], 'android');
log1.error('one');
log1.error('two');
log1.error('three');
t.equal(ringbuffer.entries.length, 5);
t.equal(ringbuffer.records.length, 5);
log1.error('four');
t.equal(ringbuffer.entries.length, 5);
t.equal(ringbuffer.entries[0]['msg'], 'android');
t.equal(ringbuffer.entries[1]['msg'], 'one');
t.equal(ringbuffer.entries[2]['msg'], 'two');
t.equal(ringbuffer.entries[3]['msg'], 'three');
t.equal(ringbuffer.entries[4]['msg'], 'four');
t.equal(ringbuffer.records.length, 5);
t.equal(ringbuffer.records[0]['msg'], 'android');
t.equal(ringbuffer.records[1]['msg'], 'one');
t.equal(ringbuffer.records[2]['msg'], 'two');
t.equal(ringbuffer.records[3]['msg'], 'three');
t.equal(ringbuffer.records[4]['msg'], 'four');
t.end();
});