Live javascript debugging by recording function ca

2019-01-23 04:50发布

问题:

This question already has an answer here:

  • Can I override the Javascript Function object to log all function calls? 6 answers

Is there a debugging system that allows me to record javascript function calls and their parameters as they occur? this would allow me to trace and debug applications in live/client situations without the performance hit due to manual logging.

Edit: I'm not talking about manually calling functions using a 'console' window and viewing the results, or manually adding 'trace' or 'log' commands into my javascript. I need it to work with any running javascript.

回答1:

Can you override Function.prototype.call and retrieve arguments and arguments.callee?

This would have the effect of reporting on ALL functions and therefore being super verbose, but maybe you'd want to filter.

Then you have the question of how you want to report, perhaps with if (console) console.log



回答2:

you could take a look at http://ajax.dynatrace.com/ajax/en/ - its IE only but pretty darn good, see this article by j. Resig : http://ejohn.org/blog/deep-tracing-of-internet-explorer/ > "..dynaTrace provides some information that I’ve never seen before – in any tool on any browser."



回答3:

@Jenko if what you're looking for something similar to an IDE debugger, in that case Internet Explorer 8 and 9 have a built-in Developer Tools (press F12) and Chrome has Developer Tools as well. Both IE and Chrome allow you to set breakpoints in your code and step through it while it's running. Firefox has Firebug, which others have mentioned, and it too allows to set breakpoints and examine the execution of your code. Opera has Dragonfly (built-in) and has the same features as the other browsers.



回答4:

As I was reading the answers and laughing at the duplicate answers of "You can use Firebug!" I realized.... you can use Firebug.

Seriously, it has a "profile" command that does exactly what you are asking for. Safari and Chrome have this feature so you can check in there as well. IE8/9 has a "profiler" tool which is similar (but I don't know if it can be called from JavaScript with console.profile())

This will give you accurate times since any code and logging you add would also afect the actual performance. And because this feature is in the top browsers, you get a reasonable amount of data.



回答5:

I've found fireflow: https://addons.mozilla.org/en-us/firefox/addon/fireflow/ incredible helpful.



回答6:

If you're talking about browser-side javascript dedub you can use Firebug, which is an excellent tool.

http://getfirebug.com/

Here you can find a step-by-step tutorial:

http://www.digitalmediaminute.com/screencast/firebug-js/



回答7:

Yes. all major browsers have a debugger built-in (IE, Chrome, Safari), or available as a add-on (Firebug for Firefox).



回答8:

Firebug is good for this. Or you can use Google Chrome's built-in debugger as well.



回答9:

for Firefox Firebug for IE deeloper tool for chrome built-in debugger is nice to use



回答10:

Arguably the best online Javascript Code Quality Controll is JSLint. It not only checks code for errors, it improves the coding style of programmes entirely<< this is the reason the author has made it in the first place. My 0,02 $

http://www.jslint.com/