Skip to content

Extend Bunyan to have default options and predefined streams etc.

License

Notifications You must be signed in to change notification settings

haishanh/bunyan-logger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bunyan Logger

Build Status Coverage Status

Extend Bunyan to have default options and predefined streams etc.

Usage

npm install bunyan-logger
const Logger = require('bunyan-logger');

Examples

Simple

const Logger = require('bunyan-logger');
const logger = new Logger({ stream: 'debug' });
logger.error(new Error('Lorem'));

With Express

See express-bunyan-logger.

const Logger = require('bunyan-logger');
const expressLogger = require('express-bunyan-logger');
app.use(expressLogger({
  logger: new Logger({ stream: 'debug' })
}));

Predefined streams

Debug

See bunyan-debug-stream.

// Simple.
const logger = new Logger({ stream: 'debug' });

// With options.
const logger = new Logger({
  name: 'myLog',
  stream: {
    name: 'debug',
    basepath: path.resolve(__dirname, '../')
  },
  serializers: require('bunyan-debug-stream').serializers
});

File

// Simple.
const logger = new Logger({ stream: 'file' });

// With options.
const logger = new Logger({
  name: 'myLog',
  stream: {
    name: 'file',
    path: './some.log'
  }
});

RingBuffer

const logger = new Logger({ stream: 'ringbuffer' });

Stdout

const logger = new Logger({ stream: 'stdout' });

Syslog

// Simple.
const logger = new Logger({ stream: 'syslog' });

// With options.
const logger = new Logger({
  name: 'myLog',
  stream: {
    name: 'syslog',
    host: '10.0.0.1'
  }
});

Extending/overriding predefined streams

See /example.

About

Extend Bunyan to have default options and predefined streams etc.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.0%
  • Makefile 7.0%