bunyan-morgan
v1.0.1
Published
Gives bunyan like (js object format) format to morgan's log format
Downloads
7,275
Maintainers
Readme
bunyan-morgan
Gives bunyan like (js object) format to morgan's log format
Install
npm install bunyan-morgan
Compatible
- express
- connect
- connect like libraries
- bunyan (as a serializer)
Usage
For Express as middleware
const bm = require('bunyan-morgan');
const app = require('express')();
app.use(bm('combined')); // pass morgan's predefined format
app.use('/', (req,res,next)=>{
res.send('test');
});
app.listen(3000);
For Express as bunyan serializer
const bunyan = require('bunyan');
const bm = require('bunyan-morgan');
const app = require('express')();
let logger = bunyan.createLogger({
name: 'my_app',
serializers: {
morgan: bm.morgan('combined') // pass morgan's predef format here
}
});
app.use('/', (req,res,next)=>{
log.info({morgan:{res, req}}, 'morgan-esque log');
res.send('test');
});
app.listen(3000);
Morgan's Predefined formats
Format of morgan not yet supported
dev
Test
npm test