process-winston

Simplifies sharing a process wide Winston.

npm install process-winston
4 downloads in the last month

process-winston Build Status

process-winston allows the configuration of a process wide winston instance that can be used by all modules. This allows the main module to configure a winston instance and all other modules to share one configuration.

Why?

Because modules want to log stuff.

How?

Setup process-winston as soon as possible in your main application like so:

var logger = require('process-winston').init(require('winston', {
  console: {
    level: 'warn',
    colorize: 'true'
  }
})).add('mylogger', {console: {level: 'info'}});

The second argument to process-winston's init method is the default logging information to apply to all loggers. All default options are deep-extended into the options passed when adding a logger. Modules find their loggers like so:

var log = require('process-winston').get('modulename');

and then they just use the logger.

Now if you want to see lots of logging from the module named modulename you'd change the initialization section in the main application to be this:

var pwinston = require('process-winston').init(require('winston', {
  console: {
    level: 'warn',
    colorize: 'true'
  }
})),
    logger = pwinston.add('mylogger', {console: {level: 'info''}});
pwinston.add('modulename', {console: {level: 'silly'}});
npm loves you