On Mon, Dec 18, 2017 at 4:13 PM, Brian Grinstead <
bgrin...@mozilla.com>
wrote:
A few of these cases would have used maxLogLevelPref if they were written
today but were converted to use the ternary operator to preserve backwards
compatibility for profiles that already had a boolean pref set with custom
dump() logging.
> 2) maxLogLevelPref being set as a way to control which logs are seen by a
> pref which is presumably something you change in a dev profile but the
> default pref value prevents any logs from showing up (i.e.
> dom.push.loglevel /
https://searchfox.org/mozilla-
> central/source/dom/push/Push.js#19).
>
Or the pref defaults to Warn or Error so Debug logs don't show up by
default but can be toggled at runtime via the pref.
My suspicion is that (2) *is* actually used by firefox devs and is
> something that we’ll need to continue supporting somehow (possibly in a
> stripped down version of Console.jsm that you could import if you need to
> use this feature). But I’d like to confirm that it is used before we do the
> work to support it. Here are the files where maxLogLevelPref is referenced:
>
> * browser/components/downloads/DownloadsCommon.jsm
> * browser/components/migration/ESEDBReader.jsm
> * browser/components/uitour/UITour.jsm
> * browser/extensions/formautofill/FormAutofillUtils.jsm
> * browser/extensions/formautofill/MasterPassword.jsm
> * browser/extensions/pocket/content/AboutPocket.jsm
> * browser/tools/mozscreenshots/mozscreenshots/extension/Screenshot.jsm
> * dom/push/Push.js
> * dom/push/PushDB.jsm
> * dom/push/PushService.jsm
> * dom/push/PushServiceAndroidGCM.jsm
> * dom/push/PushServiceHttp2.jsm
> * dom/push/PushServiceWebSocket.jsm
> * toolkit/components/extensions/ExtensionUtils.jsm
> * toolkit/components/payments/content/paymentDialogFrameScript.js
> * toolkit/components/payments/paymentUIService.js
>
> Could you please reply if you work with any of these files and take
> advantage of this feature in local development?
The point of the maxLogLevelPref feature is to be able to
flip a pref to toggle log levels at runtime. This isn't just used for
local development, it's also used for collecting logs from bug reporters.
Having a live pref allows for gathering logs in some cases which would be
hard to reproduce after a restart (e.g. if env. vars were used instead) and
flipping prefs is much easier for end users.
One of the main benefits of Console.jsm over Log.jsm is that it can log JS
objects which can be inspected/expanded/referenced in the console and I
hope that is preserved with bug 1425574. I hope the log prefix will also
continue to be formatted specially as it really helps in scanning logs.
I regularly use this feature with the following files:
* browser/components/uitour/UITour.jsm
* browser/extensions/formautofill/FormAutofillUtils.jsm
* browser/extensions/formautofill/MasterPassword.jsm
* browser/tools/mozscreenshots/mozscreenshots/extension/Screenshot.jsm
* toolkit/components/payments/content/paymentDialogFrameScript.js
* toolkit/components/payments/paymentUIService.js
I think the person who added the next most would be Kit with the Push ones.
Thanks,
Matthew
P.S. I would be fine with replacing Console.jsm usage with Log.jsm if
Log.jsm required much less boilerplate to observe a pref for the log level
and supported rich logging of objects out of the box (bug 1072687)