Last active
July 13, 2017 14:39
-
-
Save emkamal/2ef01b6fe9306fb08681c9c18bf166f2 to your computer and use it in GitHub Desktop.
A little extension to the good ol' console.log
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 kamal_javascript_debugger = function(text, obj, showtrace=true){ | |
var initChar = "\uD83E\uDC36 "; | |
if(showtrace){ | |
var stack = (new Error).stack; | |
stack = stack.split('\n').map(function (line) { return line.trim(); }); | |
stack = stack.splice(stack[0] === 'Error' ? 2 : 1); | |
} | |
if(typeof text === "object" && obj === undefined){ | |
obj = text; | |
showtrace ? console.log(initChar, obj, stack[0], [stack]) : console.log(initChar, obj); | |
} | |
else{ | |
showtrace ? console.log(initChar+text+" ["+stack[0]+"]", [stack]) : console.log(initChar+text); | |
if(obj) console.log(initChar,obj); | |
} | |
} | |
if(!window.x){ | |
window.x = kamal_javascript_debugger; | |
} | |
else if(!window.dbug){ | |
window.dbug = kamal_javascript_debugger; | |
} | |
else if(!window.xDebug) { | |
window.xDebug = kamal_javascript_debugger; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment