Bug 1030464 - log mozApps debug messages only if pref is set; r=fabrice
authorMyk Melez <myk@mozilla.org>
Mon, 30 Jun 2014 17:27:34 -0700
changeset 191636 9b8852d38b14c72dbca56b3efaf35b03aabe38b8
parent 191635 95c7e00d68b467acb622bf8e8a0e41d7a9dccc66
child 191637 ba6b27e2b92a4c64262bcbb20c83814534e5e01e
push id27055
push usercbook@mozilla.com
push dateTue, 01 Jul 2014 12:01:46 +0000
treeherdermozilla-central@4a9353b5762d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs1030464
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1030464 - log mozApps debug messages only if pref is set; r=fabrice
dom/apps/src/Webapps.jsm
modules/libpref/src/init/all.js
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -69,26 +69,26 @@ XPCOMUtils.defineLazyGetter(this, "libcu
   Cu.import("resource://gre/modules/systemlibs.js");
   return libcutils;
 });
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
 // On Android, define the "debug" function as a binding of the "d" function
 // from the AndroidLog module so it gets the "debug" priority and a log tag.
-// We always report debug messages on Android because it's hard to use a debug
-// build on Android and unnecessary to restrict reporting, per bug 1003469.
+// We always report debug messages on Android because it's unnecessary
+// to restrict reporting, per bug 1003469.
 let debug = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
               .AndroidLog.d.bind(null, "Webapps");
 #else
-function debug(aMsg) {
-#ifdef DEBUG
-  dump("-*- Webapps.jsm : " + aMsg + "\n");
-#endif
-}
+// Elsewhere, report debug messages only if dom.mozApps.debug is set to true.
+// The pref is only checked once, on startup, so restart after changing it.
+let debug = Services.prefs.getBoolPref("dom.mozApps.debug")
+              ? (aMsg) => dump("-*- Webapps.jsm : " + aMsg + "\n")
+              : (aMsg) => {};
 #endif
 
 function getNSPRErrorCode(err) {
   return -1 * ((err) & 0xffff);
 }
 
 function supportUseCurrentProfile() {
   return Services.prefs.getBoolPref("dom.webapps.useCurrentProfile");
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -4044,16 +4044,22 @@ pref("dom.mozApps.maxLocalId", 1000);
 // *any* certificate trusted; we don't try to maintain a strong
 // association between certificate with installOrign. The
 // expectation here is that in production builds the pref will
 // contain exactly one origin. However, in custom development
 // builds it may contain more than one origin so we can test
 // different stages (dev, staging, prod) of the same app store.
 pref("dom.mozApps.signed_apps_installable_from", "https://marketplace.firefox.com");
 
+// Whether or not to dump mozApps debug messages to the console.
+// Only checked on startup, so restart after changing this pref.
+// Ignored on Android, where we always report debug messages because it's
+// unnecessary to restrict reporting, per bug 1003469.
+pref("dom.mozApps.debug", false);
+
 // Minimum delay in milliseconds between network activity notifications (0 means
 // no notifications). The delay is the same for both download and upload, though
 // they are handled separately. This pref is only read once at startup:
 // a restart is required to enable a new value.
 pref("network.activity.blipIntervalMilliseconds", 0);
 
 // If true, reuse the same global for everything loaded by the component loader
 // (JS components, JSMs, etc).  This saves memory, but makes it possible for