Allow to `dump` and `console.log` to `MOZ_LOG`
Categories
(Core :: XPCOM, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox88 | --- | fixed |
People
(Reporter: nalexander, Assigned: nalexander)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Use case first. I want to capture logs for multiple independent Gecko/Firefox invocations happening over time. That is, I'm going to run Firefox in a special background task/maintenance mode every X hours, and I want to be able to log each run. I want to capture a cumulative historical log. I need to be able to log at many different levels of the Gecko/Firefox stack, which means that capturing all output produced would be optimal. However, not all OS-level task scheduling APIs (e.g., Windows Task Scheduler, macOS launchd, etc) will allow to capture an ongoing historical log of this sort. Therefore, I want to use Gecko's internal logging mechanisms. Since we have so many the best I can do is try to use one of the lowest level mechanisms in Gecko.
In this new background task mode it's entirely reasonable to set browser.dom.window.dump.enabled
all the time, so that console.log
and friends end up in dump
. I'd like to send dump
output to MOZ_LOG
as well, around https://searchfox.org/mozilla-central/rev/c03e8de87cdb0ce0378c0886d3c0ce8bbf9dc44e/js/xpconnect/loader/mozJSComponentLoader.cpp#133. Because that API is used only from JS, I don't anticipate threading or re-entrancy issues. Since dump
is unusual I don't think the overhead of an additional MOZ_LOG
call is likely to be a performance bottleneck, but others may know better.
Assignee | ||
Comment 1•5 years ago
|
||
I'll note that it would be nice to have Log.jsm
logs with a specified module (say Toolkit.Telemetry.*
) end up in MOZ_LOG
with a matching module, but that's a great deal more effort than the one-line change this ticket tracks.
Assignee | ||
Comment 2•4 years ago
|
||
By extension, this makes console.log
and friends log to the MOZ_LOG
system when browser.dom.window.dump.enabled
is true.
My immediate use case is capturing cumulative logs for the new
--backgroundtask ...
mode that will be used to invoke maintenance
tasks when Firefox itself is not running.
This will lead to duplicate messages (from both the MOZ_LOG system and
fputs
) when the MOZ_LOG system is not redirected but there's no
particular harm in that. In the future, we could not fputs
when the
MOZ_LOG system will log the given message, but it seems better to
actually do the work to connect the Log.jsm
and ConsoleAPI.jsm
systems to MOZ_LOG rather than continue to add work arounds.
Updated•4 years ago
|
Updated•4 years ago
|
Comment 4•4 years ago
|
||
bugherder |
Description
•