Utility module that adds funcitonality to native node daemons.
There are two main components, the Controller and the Logger. The Controller monitors and manages the node script. The logger wraps general logging, making it easier to output to the native system and error logs.
manager.Logger singleton class allows developers to replace
console methods with their own functions for:
If these methods aren't overridden, the default methods from
console will be used.
Strip Console Colors
The logger also has a configuration attribute called
stripColors, which will strip any console color information from the logs.
This is useful when a script should output color-coded information to the screen during development, but not in production.
The logger can optionally prefix and postfix messages with static text. For example, if the
info log should have the word
before each message, it can be configured like:
var logger =preInfo: 'INFO: 'postInfo: ' << End Info`});logger.info('my message'); // <--- Outputs Info: my message << End Info
Each method has a pre and post configuration option.
The logger has a unique configuration option called
findReplace. This can be used to find and replace text in a log message. For example, the following
configuration will put the date in front of every log:
var logger =preLog: '[DATE]: 'findReplace:return toLocaleString;;logger.log'my message'; // <-- Outputs Mon Nov 25 2013 20:35:01 GMT-0600 (Central Standard Time): my message
The date in the aforementioned example would of course be the current date.