I am using winston node module(here).
var path = '/logs/mylog.log'
var logger = new(winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: path})
]
});
My problem is that, I want to do some coding just after saving this file but i am not getting how can i add the callback function which will execute just after saving log file. I tried to do:
var logger = new(winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: path},function(){
})
]
});
but nothing is happening. Can anyone help me?
You can use the logging
event for that:
logger.on('logging', function(transport) {
// check if this was the `File` transport
if (transport.name === 'file') {
console.log('logged a message to', transport.filename);
}
});