Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

assertnotnull/bunyan-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bunyan loader

Provides a simple way to cache the bunyan instance.

Also automatically sends uncaught exceptions to logged by bunyan

It passes the config of bunyan

var bunyanconfig = {
        name: 'myapp',
        streams: [{
            level: 'INFO',
            stream: process.stdout
        }]
    };

See: https://github.com/trentm/node-bunyan#constructor-api

Instantiate once using

var bunyan = require('bunyan-loader')(bunyanconfig);
bunyan.info('i am logging')

Then reuse it in other modules by calling require without the config:

var logger = require('bunyan-loader')()
logger.info('blabla')`

var childlogger = logger.child({'scope': 'mycurrentfile'}); childlogger.info('i have more properties!')

How to use:

  • using the local bunyan: NODE_ENV=development nodemon server.js|./node_modules/.bin/bunyan
  • using global bunyan: NODE_ENV=development nodemon server.js|bunyan

About

A small module to ease and normalize the initialization of bunyan

Resources

Stars

Watchers

Forks

Packages

No packages published