Search code examples
node.jswinston

winston:how to change timestamp format


I am using winston to add log details in node.js, i used the following procedure to add the logs

 var winston = require('winston');         
 winston.remove(winston.transports.Console);
 winston.add(winston.transports.Console, {'timestamp':true,'colorize':true);
 winston.log('info','jjjj');

the output that i got is

2012-12-21T09:32:05.428Z - info: jjjj

I need to specify a format for mytimestamp , is there any provision to do so in winston any help will be much appreciated


Solution

  • The timestamp option can be a function that returns what you wish it to be saved as...

    Line 4:

    winston.add(winston.transports.Console, {'timestamp':function() {return '111111111'; },'colorize':true});
    

    Source here: https://github.com/flatiron/winston/pull/120