Created
October 30, 2014 14:50
-
-
Save WebRTCGame/6ed9651f586438dc5b96 to your computer and use it in GitHub Desktop.
Colored console output
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
console.__proto__.__proto__.fLog = (function () { | |
var severityColor = function (severity) { | |
switch (severity) { | |
case 1: | |
return 'green'; | |
break; | |
case 2: | |
return 'blue'; | |
break; | |
case 3: | |
return 'yellow'; | |
break; | |
case 4: | |
return 'orange'; | |
break; | |
case 5: | |
return 'red'; | |
break; | |
default: | |
return 'white'; | |
} | |
}; | |
return function (message, severity) { | |
var theCSS = 'background: ' + severityColor(severity) + '; color: white; font: 20px/40px arial; padding: 2px 10px; text-shadow: 1px 1px 2px black, 1px -1px 2px black, -1px 1px 2px black, -1px -1px 2px black;'; | |
console.log('%c' + message, theCSS); | |
}; | |
}()); | |
console.fLog("important", 3); | |
console.fLog("important", 5); | |
console.fLog("asdfasdf", 2); | |
var exampleFunction = function () { | |
console.group(); | |
console.fLog("the message", 1); | |
console.trace(); | |
console.groupEnd(); | |
}; | |
exampleFunction(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment