npm install super-trace
import superTrace from 'super-trace';
function a(){
superTrace.headerLog("started")
b()
c()
e()
}
function b(){
superTrace.log()
d()
}
function c(){
superTrace.log()
var loop = 3;
while (loop--) {
d()
e()
}
}
function d(){
superTrace.log()
}
function e() {
superTrace.log()
}
a()
superTrace.superLog()
you will get following:
├──┴started::a path:: at internal/main/run_main_module.js:17:47 => Function.executeUserEntryPoint [as runMain] => Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a
├─────┼started-0::b path:: Function.executeUserEntryPoint [as runMain] => Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => b
├────────┴started-1::d path:: Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => b => d
├─────┼started-2::c path:: Function.executeUserEntryPoint [as runMain] => Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => c
├────────┼started-3::d path:: Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => c => d
├────────┼started-4::e path:: Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => c => e
├────────┼started-5::d path:: Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => c => d
├────────┼started-6::e path:: Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => c => e
├────────┼started-7::d path:: Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => c => d
├────────┴started-8::e path:: Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => c => e
├─────┴started-9::e path:: Function.executeUserEntryPoint [as runMain] => Function.Module._load => Module.load => Object.Module._extensions..js => Module._compile => Object.<anonymous> => a => e
just use superTrace.headerLog
as a beginning, then superTrace.log
as a step setting in functions you interested in.
finally use superTrace.superLog
you will see a call-stacks displayed as tree structure
you can use superTrace
to decode source code:
if the SuperTrace.log
was triggered by a settimeout
or something similar, then tree can not created. But you can make this superTrace.log
as a headerLog, then get the next flows.
if the SuperTrace.log
was an orphan, it will be added to the session root as a special child, It's gray when been displayed.