How to get Javascript Function Calls/Trace at Runtime

前端 未结 8 1945
天命终不由人
天命终不由人 2020-12-23 13:56

As I interact with my AJAX based application at RUNTIME I\'d like the console to spit out all the functions it\'s calling. (so no stack trace, or breakpoints, or pr

8条回答
  •  被撕碎了的回忆
    2020-12-23 14:46

    Let me throw a third (also admittedly somewhat imperfect) solution into the ring.

    Note that all other answers offer two kinds of solutions:

    1. Manually patch your JS functions in run-time, and log them to console
      • Yes it can get the job done, but will be useless once your project grows to a certain size. It does not give you sufficient controlability, unless you keep spending time on keeping on deleloping this feature.
    2. Jeff proposes using a profiler for debugging purposes
      • Not very helpful, as the profiler views (at least for now) are designed to help you analyze performance, not the call graph; does not work well, unless you spend a lot of time training yourself to getting used to the counter-productive user interface.

    That is why I wrote Dbux, a work in progress, which currently only works as a VSCode addon with some limitations. However, it is an omniscient debugger with dynamic execution analysis tools, code annotations and a full-blown dynamic call graph visualization tool, aimed at helping developers with Program Comprehension and Debugging:

    Links:

    • Dbux VSCode Extension (with a lot of documentation and some pictures)
    • Dbux Github Repo
    • Introduction Video with 2 Examples

提交回复
热议问题