[Node.js] log-timestamp: Adding Timestamps to console.log and console.error Output

Tadashi Shigeoka ·  Tue, February 3, 2015

I’ll introduce a module called log-timestamp that adds timestamps to the beginning of console.log and console.error output in Node.js.

Usage Example

> console.log('Before log-timestamp');
Before log-timestamp

> require('log-timestamp');

> console.log('After log-timestamp');
[2015-02-03T13:45:13.198Z] After log-timestamp

> console.error('Error')
[2015-02-03T14:15:18.093Z] Error

By using log-timestamp, you can output error occurrence times to error.log, which can be useful for investigating errors and bugs.


Reference Information

bahamas10/node-log-timestamp

bahamas10/node-log-prefix

That’s all from the Gemba.