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