A logger for node inspired by log4j and commons-logging.
Pince is a lightweight logger that combines some of the best properties of log4j and node. It's equally usable in Node, (most) browsers, and Meteor (client and server).
It was developed for MadEye.
npm install pince.
In any file you wish to make a logger, require it via
Logger = require('pince');
To install, just
meteor add jag:pince. The global
Logger symbol will be
there waiting for you.
By default, on the server Meteor will prepend a string to logs that includes
a timestamp (amongst other things). To silence Meteor's prefix, run meteor
Set the log level:
//Default is infoLogger;
Make a new logger:
var log = 'router';log;//2013-10-31 11:29:36.097 info: [router] Routing.log;//2013-10-31 11:29:36.101 trace: [router] Setting up routes...
Set individual levels:
Logger;Logger;var routerLog = 'router';var controllerLog = 'controller';routerLog;//NothingcontrollerLog;//2013-10-31 11:31:21.906 trace: [controller] Can hear me.Logger;routerLog;//2013-10-31 11:32:48.374 info: [router] Finally! Someone is listening to me.controllerLog;//Nothing
Hierarchically name and set levels:
var routerLog = 'myPackage:router';var controllerLog = 'myPackage:controller';Logger;Logger;routerLog;routerLog;controllerLog;