Stop using the prefix of a console as its MOZ_LOG module when it has no logModule
Categories
(DevTools :: Console, task)
Tracking
(Not tracked)
People
(Reporter: dcarver, Unassigned)
References
(Depends on 1 open bug)
Details
A console created with console.createInstance({ prefix }) and no logModule still uses its prefix as its MOZ_LOG module name. This fallback is deprecated and is only kept for compatibility with callers written before logModule existed, such as code in comm-central. Without it, such a console logs to the console module, as a console with neither a logModule nor a prefix already does.
Bug 2086992 adds the ESLint rule mozilla/console-prefix-requires-log-module, which warns about a prefix with no logModule. That rule exists only while the fallback does.
Removing the fallback needs:
- No console in the tree to be created with a
prefixand nologModule; the rule above reports them. A console that should log to theconsolemodule once the fallback is gone can say so withlogModule: "console". - Code outside the tree, such as comm-central and add-ons with privileged access, to have moved to
logModuletoo. - The
Consoleconstructor indom/console/Console.cppto stop usingaPrefixas the log module whenaLogModuleis empty, so that such a console logs to theconsolemodule. The code that keeps a prefix equal to the module name from being printed twice should be checked at the same time. - The tests of this fallback, in
dom/console/tests/xpcshell/test_console_logModule.jsandtoolkit/components/backgroundtasks/tests/BackgroundTask_console.sys.mjs, to be removed or changed to pass alogModule, along with theireslint-disablecomments for the rule.
Then remove mozilla/console-prefix-requires-log-module from the recommended configuration and from eslint-plugin-mozilla, along with its documentation page console-prefix-requires-log-module.md.
Description
•