winston-callback

3.1.5 • Public • Published

Install

npm install winston winston-callback

About

It allows you to call a handler after the completion of all transports. You must install winston by yourself. It is a peer dependency.

Example

const winston = require('winston-callback');
/* 
  or: 
  require('winston-callback');
  const winston = require('winston');  
*/

const options = {
  transports: [
    new (winston.transports.Console)({
        level: 'info',
        colorize: true
    }),
    new (winston.transports.File)({
        name: 'f1'
        filename: "logs/error.log",
        level: 'error'
    }),
    new (winston.transports.File)({
        name: 'f2'
        filename: "logs/info.log",
        level: 'info'
    })
    //... other transports
  ]
}

const logger = winston.createLogger
  ? winston.createLogger(options) // for v3
  : new (winston.Logger)(options); // for v2 

logger.error('a callback handling', function (err) {
  process.exit();
});

logger.info('a promise handling').finally(function () {
  process.exit();
});

Dependents (0)

Package Sidebar

Install

npm i winston-callback

Weekly Downloads

6

Version

3.1.5

License

MIT

Unpacked Size

6.62 kB

Total Files

5

Last publish

Collaborators

  • ortex