Node-logger library for Node.js

When you start a project log in is the first thing you will implement. In JavaScript you will logon things to the console by using console.log. Node-logger is a logging library which utilizes the simple APIs of Ruby’s logger.rb and browser-js console.log(). There are five levels of logging.

Fatal, error, warn, info, debug are those levels. Each has its own method on logging instances. At runtime you can set a maximum log level on logger. 

Here is how the instantiation is:

 // node/common.js style 
var logger = require('./logger').createLogger(); // logs to STDOUT
var logger = require('./logger').createLogger('development.log'); // logs to a file
With ‘n’ arguments joined by ‘’ you can use logging methods. sys.inspect() will string-ify arguments that are not string.
logger.info('loading an array', [1,2,3], 'now!');
//=> info [Sat Jun 12 2010 01:12:05 GMT-0400 (EDT)]  loading an array [ 1, 2, 3, [length]: 3 ] now!
logger.debug('this wont be logged');
//=> false
logger.setLevel('debug');
logger.debug('this will be logged now');
//=> debug [Sat Jun 12 2010 01:12:54 GMT-0400 (EDT)]  this will be logged now
You can also customize the design by overriding the format() method on the logger.
logger.format = function(level, date, message) {
  return date.getTime().toString() + "; " + message;
};
logger.debug('message');
//=> 1276365362167;  message