chronolog
This simple Node.js module provides an easy way to write logging messages prefixed with the current date.
Usage
First, require the module:
var chronolog = ;
It can format strings - console.log(chronolog('test message'))
will print
something like:
[2014-11-03 Mon pm 10:50:58] test message
It can wrap the console
object:
var log = ; // These will all be prefixed with the current date; // same as log.loglog;log;log;log; // These will not be prefixed with the current dateconsole;logdir'this is not prefixed either';
It can wrap stream objects:
; // Now you can do this to write a message prefixed with the current date:processstdout;
The default date format is designed to be human-readable yet still sort well.
You can change the message or the date format (the date format uses
Moment.js formatting placeholders
and the message format is passed to
util.format
):
;// returns '[22:50:58] test message' var log = ;// returns an object that writes messages with the given format ;// returns '22:50:58: test message'