Bunyan Logger
Extend Bunyan to have default options and predefined streams etc.
Usage
npm install bunyan-logger
const Logger = require('bunyan-logger');
Examples
Simple
const Logger = require('bunyan-logger');
const logger = new Logger({ stream: 'debug' });
logger.error(new Error('Lorem'));
With Express
See express-bunyan-logger.
const Logger = require('bunyan-logger');
const expressLogger = require('express-bunyan-logger');
app.use(expressLogger({
logger: new Logger({ stream: 'debug' })
}));
Predefined streams
Debug
See bunyan-debug-stream.
const logger = new Logger({ stream: 'debug' });
const logger = new Logger({
name: 'myLog',
stream: {
name: 'debug',
basepath: path.resolve(__dirname, '../')
},
serializers: require('bunyan-debug-stream').serializers
});
File
const logger = new Logger({ stream: 'file' });
const logger = new Logger({
name: 'myLog',
stream: {
name: 'file',
path: './some.log'
}
});
RingBuffer
const logger = new Logger({ stream: 'ringbuffer' });
Stdout
const logger = new Logger({ stream: 'stdout' });
Syslog
const logger = new Logger({ stream: 'syslog' });
const logger = new Logger({
name: 'myLog',
stream: {
name: 'syslog',
host: '10.0.0.1'
}
});
Extending/overriding predefined streams
See /example
.