bunyan-morgan

Gives bunyan like (js object format) format to morgan's log format

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
bunyan-morgan
001.0.18 years ago8 years agoMinified + gzip package size for bunyan-morgan in KB

Readme

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