winston:how to change timestamp format

Amanda G picture Amanda G · Dec 21, 2012 · Viewed 23.7k times · Source

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

Answer

Ben Evans picture Ben Evans · Dec 21, 2012

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