Non-breaking breakpoints (trace points) in Javascript?

This is a pretty tricky question, which may just be impossible with what is currently available, but if there was an easy way to do this, it would be huge.

I am debugging some JavaScript in Chrome, and since it is very event-driven, I prefer to receive reports about code tracing (what caused, etc.) instead of breakpoints. Therefore, wherever I leave a breakpoint, I would like to see the name and arguments of the local function.

The closest I can get is to reset a conditional breakpoint, for example:

Sample trace

With this approach, there are two big problems:

  • Inserting this at each breakpoint is too cumbersome. People will be much more likely to use it if it can be chosen as the default action for each breakpoint.
  • In Google Chrome, log calls are fired twice.

Any ideas on how to overcome any of these problems? I think this is possible in IE with VS , but the interface there seems equally cumbersome.

+5
source share
3 answers

I could not find something for this, so I wrote my own .

Now, instead of constantly inserting and deleting console.log calls, I leave the login and review it only if necessary.

Warning: the specific code below is not verified.

var debug = TraceJS.GetLogger("debug", "mousemove");
$('div').mousemove(function(evt) {
     debug(this.id, evt);
});

, DIV, [ "mousemove", {id }]

- . mousemove #a, :

TraceJS('a');

mousemove, :

TraceJS('mousemove');

, . TraceJS ( ), .

0

, , - javascript Chrome Javascript, console.log.

( , ) ( ) , .

!

+1

IE11 now has “trace points," regardless of Visual Studio. They do what you asked three years ago. I don’t see them in Chrome or other browsers, but hopefully they will catch soon!

+1
source

All Articles