Comparing version 0.4.0 to 0.5.0
@@ -126,2 +126,3 @@ "use strict"; | ||
Logger.prototype.debug = function( message ) { | ||
message = formatString.apply( this, arguments ); | ||
preLog( "[DEBUG ]", this, colors.grey, this.debug.bind( this ), message ); | ||
@@ -134,2 +135,3 @@ }; | ||
Logger.prototype.info = function( message ) { | ||
message = formatString.apply( this, arguments ); | ||
preLog( "[INFO ]", this, colors.cyan, this.info.bind( this ), message ); | ||
@@ -142,2 +144,3 @@ }; | ||
Logger.prototype.notice = function( message ) { | ||
message = formatString.apply( this, arguments ); | ||
preLog( "[NOTICE]", this, colors.green, this.notice.bind( this ), message ); | ||
@@ -150,2 +153,3 @@ }; | ||
Logger.prototype.warn = function( message ) { | ||
message = formatString.apply( this, arguments ); | ||
preLog( "[WARN ]", this, colors.yellow, this.warn.bind( this ), message ); | ||
@@ -158,2 +162,3 @@ }; | ||
Logger.prototype.error = function( message ) { | ||
message = formatString.apply( this, arguments ); | ||
preLog( "[ERROR ]", this, colors.red, this.error.bind( this ), message ); | ||
@@ -166,3 +171,4 @@ }; | ||
Logger.prototype.critical = function( message ) { | ||
preLog( "[CRITIC]", this, function( str ) {return colors.bold( colors.red( str ) ); }, this.critical.bind( this ), message ); | ||
message = formatString.apply( this, arguments ); | ||
preLog( "[CRITIC]", this, function( str ) { return colors.bold( colors.red( str ) ); }, this.critical.bind( this ), message ); | ||
}; | ||
@@ -176,2 +182,9 @@ | ||
/** | ||
* Apply util.format on the supplied arguments, as applicable. | ||
* @returns {String} The formatted string. | ||
*/ | ||
var formatString = function() { | ||
return (arguments.length) ? util.format.apply( this, arguments ) : arguments[0]; | ||
} | ||
/** | ||
* Pre-processes a logging subject. Like breaking it into further subjects or grabbing stacks from Errors. | ||
@@ -267,3 +280,4 @@ * @param {String} level The log level indicator. | ||
var generateLogStack = function( level, logger, subject, colorizer ) { | ||
var lines = subject.toString().split( "\n" ); | ||
var subjectString = (util.isArray( subject ) || typeof(subject) == "object") ? JSON.stringify( subject ) : subject.toString(); | ||
var lines = subjectString.split( "\n" ); | ||
@@ -270,0 +284,0 @@ // Most common case, a single line. |
{ | ||
"name": "fm-log", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Console logging facility for Node", | ||
@@ -5,0 +5,0 @@ "main": "lib/log.js", |
44966
487