Log JavaScript errors and warnings through MOZ_LOG
Categories
(DevTools :: Console, enhancement)
Tracking
(firefox137 fixed)
| Tracking | Status | |
|---|---|---|
| firefox137 | --- | fixed |
People
(Reporter: ochameau, Assigned: ochameau)
References
Details
Attachments
(1 external file)
Bug 1828100 started displaying/recording all calls made to JavaScript console API through MOZ_LOG.
It is handy as you can now also start debugging JavaScript codebases via MOZ_LOG.
But it is quickly frustrating as you won't see any JavaScript error (JS exception, parsing errors) or warning (CSS, CORS, tracking protection, ...).
A simple action would be to simply MOZ_LOG all the the nsIConsoleMessage's managed by nsConsoleService.
We could then either reuse the console Log module name (to match the C++ class),
or rather introduce a new module name messages, page-messages, page-console, console (and rename console to console-api/js-console), page-errors-and-warnings, js-errors,...?
Naming this is a bit tricky as it can be either info, warning or errors.
It isn't solely about JavaScript execution, but can be about requests, css, cors, cookies,...
nsConsoleService actually process either nsIConsoleMessage (which doesn't expose much beyond a log level + string),
but also nsIScriptError (which exposes many other things, including a category).
We could possibly differentiate the two and use two distinct module names.
We could also especially differentiates the nsIScriptError's through their category.
My motivation to work on this is to provide an easy way for WebCompat to record a sampling or tracing profile, which would include page errors and notices. This is to me very high value and it sounds better to invest into exposing this via MOZ_LOG rather than introducing custom profiler markers. I would have similar naming issues, and this wouldn't benefit overall Firefox debugging through MOZ_LOG.
| Assignee | ||
Comment 1•2 years ago
|
||
| Assignee | ||
Comment 2•2 years ago
|
||
Note that such feature will make the following logs to stderr redundant, if not obsolete:
https://searchfox.org/mozilla-central/rev/3265b390bd5d08a5be520253ef71835bcb715f27/js/xpconnect/src/nsXPConnect.cpp#270-304
| Assignee | ||
Comment 3•2 years ago
|
||
While opening bug 1925323, I realized that profiler and about:logging presets may align on some cases.
And I was wondering if that could be worth toggling about:logging modules from the profiler popup when we select a profiler preset that matches an about:logging preset.
Updated•1 year ago
|
Comment 5•1 year ago
|
||
| bugherder | ||
Description
•