bunyan-morgan

1.0.1 • Public • Published

bunyan-morgan

Build Status Dependency Status Coverage Status

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

Package Sidebar

Install

npm i bunyan-morgan

Weekly Downloads

867

Version

1.0.1

License

MIT

Last publish

Collaborators

  • shriek