Created
March 13, 2014 08:21
-
-
Save mindon/9524222 to your computer and use it in GitHub Desktop.
A Simple JavaScript trace function for QML (BlackBerry 10)
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
// trace callstack | |
// by Mindon from http://mindon.github.io | |
function trace() { | |
var callstacks = []; | |
var fn = arguments.callee.caller; | |
while (fn) { | |
var fnstr = fn.toString(); | |
fnstr = fnstr.substring(fnstr.indexOf("function") + 8, fnstr.indexOf('{')).replace(/^\s+|\s+$/g, ''); | |
var fname = fnstr == '()' ? '(anonymous function)': fnstr; | |
callstacks.push(fname); | |
fn = fn.caller; | |
} | |
console.debug("[CALLSTACK]: " + callstacks.reverse().join(' -> ')); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment