Open Bug 2095093 Opened 5 days ago

Stop using the prefix of a console as its MOZ_LOG module when it has no logModule

Categories

(DevTools :: Console, task)

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:

  1. No console in the tree to be created with a prefix and no logModule; the rule above reports them. A console that should log to the console module once the fallback is gone can say so with logModule: "console".
  2. Code outside the tree, such as comm-central and add-ons with privileged access, to have moved to logModule too.
  3. The Console constructor in dom/console/Console.cpp to stop using aPrefix as the log module when aLogModule is empty, so that such a console logs to the console module. The code that keeps a prefix equal to the module name from being printed twice should be checked at the same time.
  4. The tests of this fallback, in dom/console/tests/xpcshell/test_console_logModule.js and toolkit/components/backgroundtasks/tests/BackgroundTask_console.sys.mjs, to be removed or changed to pass a logModule, along with their eslint-disable comments 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.

You need to log in before you can comment on or make changes to this bug.