JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7632
  • Score
    100M100P100Q136617F
  • License BSD

a bunyan logger middleware for express

Package Exports

  • express-bunyan-logger

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-bunyan-logger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Express-bunyan-logger

A express logger middleware powered by bunyan.

Build Status

Installation

npm install express-bunyan-logger

Usage

To use the logger:

app.use(require('express-bunyan-logger')());

To use the errorLogger:

app.use(require('express-bunyan-logger').errorLogger());

And you can also pass bunyan logger options to the logger middleware:

app.use(require('express-bunyan-logger')({
    name: 'logger', 
    streams: [{
        level: 'info',
        stream: process.stdout
        }]
    }));

Change default format:

app.use(require('express-bunyan-logger')({
    format: ":remote-address - :user-agent[major] custom logger"
});

Configuration

options.format

Format string, please go the source code to the metadata. ":name" will print out meta.name; ":name[key]" will print out the property 'key' of meta.name.

Or you can pass a function to options.format. This function accept a object as argument and return string.

options.parseUA

Whether to parse user-agent in logger, default is =true=.

options.levelFn

Function that translate statusCode into log level.

function(status, err /* only will work in error logger */) {
     // return string of level
     return "info";
}

options.immediate

Write log line on request instead of response (for response times)

License

(The BSD License)

Copyright (c) 2013, Villa.Gao <jky239@gmail.com>;