Created
March 2, 2015 12:27
-
-
Save RazZziel/8b22cdbbe93397d261fb to your computer and use it in GitHub Desktop.
Colorify console.log() familly of functions
This file contains hidden or 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
# 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