Last active
February 3, 2016 18:19
-
-
Save yoannmoinet/a6040e22695d8617d8cf to your computer and use it in GitHub Desktop.
Will output in the console what the stack is at the moment this is called.
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
// nb [int] the number of line to get from the stack | |
function logStack (nb) { | |
try { | |
throw new Error(); | |
} catch (e) { | |
var stack = e.stack.match(/(https?:\/\/[\w.:0-9\/]+)/g); | |
if (nb === undefined) { | |
nb = stack.length - 2; | |
} | |
console.log( | |
'- Stack(' + nb + ') :\n ' + | |
_.first(_.last(stack, stack.length - 2), nb) | |
.join('\n ') | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment