1.0.1 • Published 8 years ago

bunyan-morgan v1.0.1

Weekly downloads
519
License
MIT
Repository
github
Last release
8 years ago

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