Adding timestamps to all console messages

前端 未结 12 1267
鱼传尺愫
鱼传尺愫 2021-01-31 06:51

I have a complete, deployed, Express-based project, with many console.log() and console.error() statements throughout. The project runs using forever, directing the st

12条回答
  •  耶瑟儿~
    2021-01-31 07:34

    Use event listener like this,

    process.on('error', function() { 
       console.log('Error Occurred.');
    
       var d = Date(Date.now()).toString();
       console.log.call(console, d); // Wed Aug 07 2019 23:40:07 GMT+0100 (GMT+01:00)
    });
    

    happy coding :)

提交回复
热议问题