Skip to content

Instantly share code, notes, and snippets.

@RazZziel
Created March 2, 2015 12:27
Show Gist options
  • Save RazZziel/8b22cdbbe93397d261fb to your computer and use it in GitHub Desktop.
Save RazZziel/8b22cdbbe93397d261fb to your computer and use it in GitHub Desktop.
Colorify console.log() familly of functions
# Inspiration:
# http://zurb.com/forrst/posts/Add_color_to_console_warn_and_console_error_outp-Go0
# https://gist.github.com/spmason/1670196
try {
var colors = require('colors');
var util = require('util');
var makeColorConsole = function(fct, color){
return function() {
var args = [util.format.apply(util.format, Array.prototype.slice.call(arguments))];
fct(Array.prototype.join.call(args," ")[color]);
};
}
console.info = makeColorConsole(console.warn, "cyan");
console.warn = makeColorConsole(console.warn, "yellow");
console.error = makeColorConsole(console.error, "red");
} catch (err) {
console.error("No color support");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment