gsf / logstamp

Prefix log messages with a timestamp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logstamp Build Status

Overrides the console's stdout and stderr streams to prefix each log message with a stamp. Similar to https://github.com/bahamas10/node-log-timestamp but console methods are untouched, so things like console.log's application of util.format still work.

Examples

console.log('Object: %s', 'myRobot', {number: 5});
require('logstamp')();
console.log('Object: %s', 'myRobot', {number: 5});

Output:

Object: myRobot { number: 5 }
2013-08-17T21:37:16.212Z Object: myRobot { number: 5 }

If desired, a custom stamp can also be set:

require('logstamp')(function () {
  return Date.now() + ' Server X ';
});
console.log([1, 2, 3]);

Output:

1378137011853 Server X [ 1, 2, 3 ]

About

Prefix log messages with a timestamp


Languages

Language:JavaScript 100.0%