Bug 1426250 - allow changing log preference at runtime for CUI.jsm, r?jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 05 Jan 2018 21:31:53 +0000
changeset 719596 ba2cfa8ab8d6d2410acd47db22135a02c7b1772e
parent 719595 b7554b5575905e301055cd7715fc997429e7c9f8
child 719597 8abbfc71b338383da55091107611146ae1de25cc
push id95298
push usergijskruitbosch@gmail.com
push dateFri, 12 Jan 2018 11:50:25 +0000
reviewersjaws
bugs1426250
milestone59.0a1
Bug 1426250 - allow changing log preference at runtime for CUI.jsm, r?jaws MozReview-Commit-ID: 47V7Aa8eM1N
browser/components/customizableui/CustomizableUI.jsm
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -154,22 +154,29 @@ var gUIStateBeforeReset = {
   uiCustomizationState: null,
   drawInTitlebar: null,
   extraDragSpace: null,
   currentTheme: null,
   uiDensity: null,
   autoTouchMode: null,
 };
 
+XPCOMUtils.defineLazyPreferenceGetter(this, "gDebuggingEnabled", kPrefCustomizationDebug, false,
+  (pref, oldVal, newVal) => {
+    if (typeof log != "undefined") {
+      log.maxLogLevel = newVal ? "all" : "log";
+    }
+  }
+);
+
 XPCOMUtils.defineLazyGetter(this, "log", () => {
   let scope = {};
   Cu.import("resource://gre/modules/Console.jsm", scope);
-  let debug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
   let consoleOptions = {
-    maxLogLevel: debug ? "all" : "log",
+    maxLogLevel: gDebuggingEnabled ? "all" : "log",
     prefix: "CustomizableUI",
   };
   return new scope.ConsoleAPI(consoleOptions);
 });
 
 var CustomizableUIInternal = {
   initialize() {
     log.debug("Initializing");