Skip to content

gsf/logstamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

Stars

Watchers

Forks

Packages

No packages published