2012-06-19 21:36:02 +00:00
|
|
|
/*
|
|
|
|
* Test the RingBuffer output stream.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var test = require('tap').test;
|
|
|
|
var Logger = require('../lib/bunyan');
|
|
|
|
var ringbuffer = new Logger.RingBuffer({ 'limit': 5 });
|
|
|
|
|
|
|
|
var log1 = new Logger({
|
|
|
|
name: 'log1',
|
|
|
|
streams: [
|
|
|
|
{
|
|
|
|
stream: ringbuffer,
|
2012-06-20 23:26:28 +00:00
|
|
|
raw: true,
|
2012-06-19 21:36:02 +00:00
|
|
|
level: 'info'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
test('ringbuffer', function (t) {
|
|
|
|
log1.info('hello');
|
|
|
|
log1.trace('there');
|
2012-06-20 17:39:56 +00:00
|
|
|
log1.error('android');
|
2012-06-19 21:36:02 +00:00
|
|
|
t.equal(ringbuffer.entries.length, 2);
|
|
|
|
t.equal(ringbuffer.entries[0]['msg'], 'hello');
|
2012-06-20 17:39:56 +00:00
|
|
|
t.equal(ringbuffer.entries[1]['msg'], 'android');
|
2012-06-19 21:36:02 +00:00
|
|
|
log1.error('one');
|
|
|
|
log1.error('two');
|
|
|
|
log1.error('three');
|
|
|
|
t.equal(ringbuffer.entries.length, 5);
|
|
|
|
log1.error('four');
|
|
|
|
t.equal(ringbuffer.entries.length, 5);
|
2012-06-20 17:39:56 +00:00
|
|
|
t.equal(ringbuffer.entries[0]['msg'], 'android');
|
2012-06-19 21:36:02 +00:00
|
|
|
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.end();
|
|
|
|
});
|