logly
logly
is a small logging framework in the nodejs
ecosystem that also allows one to set debug
or verbose
logging modes.
It is useful to replace comments that describe what the code is doing, especially in debug
mode.
Usage
var logly = ; loglyname 'myapp' ;logly; logly;// stdout: myapp[debug]: debug log logly;// stdout: myapp[verbose]: verbose log logly;// stdout: myapp: standard log logly;// stderr: myapp[warn]: warning log logly;// stderr: myapp[error]: error log logly;// stdout: stdout log// *above does not include 'myapp' logly;// stderr: stderr log// *above does not include 'myapp'
functions as input
logly
also accepts functions as input; this is primarily to conditionally produce a debug output of complex something if in debug
mode, for example:
var options = debug: true output: "some.file" // dump options in debug modelogly;// stdout: myapp[debug]: [OPTION] debug: true// stdout: myapp[debug]: [OPTION] output: some.file
Options
color/colour
If you want color then you can enable it (by default color is disabled):
loglyoptions color : true ;
You can also use color
or colour
functions (maintained for backward compatibility):
loglycolortrue;logly;
date
You can include a date prefix as well:
loglyoptions date : true ;logly;// stdout: Wed Aug 22 2012 21:22:52 GMT-0500 (CDT) myapp: with date
ISO8601 format is also available:
loglyoptions date : 'iso' ; // or 'ISO8601', 'iso8601', 'ISO'logly;// stdout: 2012-08-23T02:26:14.841Z myapp: with iso date
processors
You can do string processing:
var processors = ;processors;loglyoptions processors: processors ;logly;// stdout: logly: some newlines here and there
options
object
You can pass in the above options all together:
var processors = ;processors;loglyoptions colour : true date : 'iso' processors: processors ;