Fork me on GitHub Log.js

Log.js

Tiny logger for NodeJS.

log

lib/log.js

Initialize a Loggeer with the given log level defaulting to DEBUG and stream defaulting to stdout.

  • param: Number level

  • param: Object stream

  • api: public

var Log = exports = module.exports = function Log(level, stream){
  this.level = level || exports.DEBUG;
  this.stream = stream || process.stdout;
};

System is unusable.

  • type: Number

exports.EMERGENCY = 0;

Action must be taken immediately.

  • type: Number

exports.ALERT = 1;

Critical condition.

  • type: Number

exports.CRITICAL = 2;

Error condition.

  • type: Number

exports.ERROR = 3;

Warning condition.

  • type: Number

exports.WARNING = 4;

Normal but significant condition.

  • type: Number

exports.NOTICE = 5;

Purely informational message.

  • type: Number

exports.INFO = 6;

Application debug messages.

  • type: Number

exports.DEBUG = 7;

prototype.

Log.prototype = {

Log emergency msg.

  • param: String msg

  • api: public

emergency: function(msg){
    this.log('EMERGENCY', msg);
  },

Log alert msg.

  • param: String msg

  • api: public

alert: function(msg){
    this.log('ALERT', msg);
  },

Log critical msg.

  • param: String msg

  • api: public

critical: function(msg){
    this.log('CRITICAL', msg);
  },

Log error msg.

  • param: String msg

  • api: public

error: function(msg){
    this.log('ERROR', msg);
  },

Log warning msg.

  • param: String msg

  • api: public

warning: function(msg){
    this.log('WARNING', msg);
  },

Log notice msg.

  • param: String msg

  • api: public

notice: function(msg){
    this.log('NOTICE', msg);
  },

Log info msg.

  • param: String msg

  • api: public

info: function(msg){
    this.log('INFO', msg);
  },

Log debug msg.

  • param: String msg

  • api: public

debug: function(msg){
    this.log('DEBUG', msg);
  }
};