Skip to content

Instantly share code, notes, and snippets.

@adrienjoly
Created February 13, 2014 10:58
Show Gist options
  • Save adrienjoly/8973199 to your computer and use it in GitHub Desktop.
Save adrienjoly/8973199 to your computer and use it in GitHub Desktop.
add color to console.warn and console.error outputs
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