node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

bunyan-adaptor

Bunyan Adaptor

Maps the major Bunyan logging methods to custom methods. Useful for fitting your own logging system with a module expecting a Bunyan interface. For a simple console.log()/.error() mapping see Bunyan Duckling

Installation

npm install bunyan-adaptor --save

Syntax

var logger = bunyanAdaptor(options);

Usage

Simple:

var logger = require('bunyan-adaptor')({
  log: console.log.bind(console),
  error: console.error.bind(console),
});
 
logger.error('Warning');      // Uses console.error() 
logger.info('Informational'); // Uses console.log() 

Options

Maps options methods to all seven Bunyan log levels.

  • .fatal() – maps to options.fatal and fallbacks to options.error and options.log in that order
  • .error() – maps to options.error and fallbacks to options.error and options.log in that order
  • .warn() – maps to options.warn and fallbacks to options.log
  • .info() – maps to options.info and fallbacks to options.log
  • .debug() – maps to options.debug and fallbacks to options.verbose and options.log in that order
  • .trace() – maps to options.trace and fallbacks to options.verbose and options.log in that order

options.log itself fallbacks to console.log()