0.0.2-2 • Published 11 years ago

nm-logger v0.0.2-2

Weekly downloads
17
License
-
Repository
github
Last release
11 years ago

nm-logger

nm-logger is a wrapper around Winston logger for NodeJS. For every log call it automatically adds the date and time as well as the file name and line number at which the log message was executed.

The following parameters can be configured via the "init" function call:

logToConsole - whether you want to log everything to the console as well logLevel - as supported by Winston (e.g. debug, info, error, warn). If none is specified, log level is set to error filePath - absolute path to log file. If none is specified, the file path is set to /tmp/nm-logger.log maxsize - file max size. The default is 50MB maxFiles - max number of log files. The default is 10

Usage

A basic example for using nm-logger.

(function() { var loggerManager = require('../lib/nm-logger');

loggerManager.init({logToConsole:true, filePath:'/tmp/example.log', logLevel:'debug'});

var logger = loggerManager.getLogger();

logger.debug('This is a debug message');

})();

The code above will produce the following message:

debug: 2013/09/20 21:23:49:653 : example1.js:8 : This is a debug message