Created
February 13, 2014 10:58
-
-
Save adrienjoly/8973199 to your computer and use it in GitHub Desktop.
add color to console.warn and console.error outputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colors = require('colors'); | |
function makeColorConsole(fct, color){ | |
return function(){ | |
for (var i in arguments) | |
if (arguments[i] instanceof Object || arguments[i] instanceof Array) | |
arguments[i] = sys.inspect(arguments[i]); | |
fct(Array.prototype.join.call(arguments, " ")[color]); | |
}; | |
} | |
console.warn = makeColorConsole(console.warn, "yellow"); | |
console.error = makeColorConsole(console.error, "red"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment