What's a good snippet to safely instrument "almost all functions" using stacktrace.js?

381 views Asked by At

stacktrace.js is a micro-library for getting stack traces in all web browsers.

It offers functions instrumentation:

var p = new printStackTrace.implementation();
p.instrumentFunction(this, 'baz', logStackTrace);
function logStackTrace(stack) {
    console.log(stack.join(' -> '));
}
function foo() {
    var a = 1;
    bar();
}
function bar() {
    baz();
}
foo(); //Will log a stacktrace when 'baz()' is called containing 'foo()'!

p.deinstrumentFunction(this, 'baz'); //Remove function instrumentation

What's the best way to "instrument all or almost all functions" in a safe way? Basically I want (say ... in "debug mode") to "auto-catch and log" all stack traces from all functions that are feasible to instrument. What's a good snippet to do this? Which functions should I avoid instrumenting?

0

There are 0 answers