UNPKG

bunyan-formatter

Version:

Writable stream that formats bunyan records that are piped into it.

49 lines (39 loc) 1.16 kB
'use strict'; var bunyan = require('bunyan') , bformat = require('../') , test = require('tap').test ; function inspect(obj, depth) { console.error(require('util').inspect(obj, false, depth || 5, true)); } describe('simple', () => { beforeAll(() => { writes = []; }); var formatOut = bformat({ outputMode: 'simple'}, { write: onwrite }) var log = bunyan.createLogger({ name: 'app', stream: formatOut, level: 'debug' } ); var writes = []; function onwrite (c) { writes.push(c) } it('info', () => { log.info('starting up'); expect(writes).toMatchSnapshot(); }); it('debug', () => { log.debug('things are heating up', { temperature: 80, status: { started: 'yes', overheated: 'no' } }); expect(writes).toMatchSnapshot(); }); it('warn', () => { log.warn('getting a bit hot', { temperature: 120 }); expect(writes).toMatchSnapshot(); }) it('error', () => { log.error('OOOOHHH it burns!', new Error('temperature: 200')); expect(writes).toMatchSnapshot(); }) it('fatal', () => { log.fatal('I died! Do you know what that means???'); expect(writes).toMatchSnapshot(); }); });