Skip to content

Instantly share code, notes, and snippets.

@ezmiller
Created January 19, 2016 16:54
Show Gist options
  • Save ezmiller/77bbcaa9f560a0f76a2c to your computer and use it in GitHub Desktop.
Save ezmiller/77bbcaa9f560a0f76a2c to your computer and use it in GitHub Desktop.
How to log a strack trace anywhere in Javascript
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