winston-callback
v3.1.5 winston callback async flush sync close after transports all and 1 more...
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();
});
npm i winston-callback
Metadata
- MIT
- >=5.0.0
- Balasyan Alexandr
- released 6/4/2021