Created
January 19, 2016 16:54
-
-
Save ezmiller/77bbcaa9f560a0f76a2c to your computer and use it in GitHub Desktop.
How to log a strack trace anywhere in Javascript
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 e = new Error('dummy'); | |
var stack = e.stack.replace(/^[^\(]+?[\n$]/gm, '') | |
.replace(/^\s+at\s+/gm, '') | |
.replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') | |
.split('\n'); | |
console.log(stack); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment