Bug 1464469 - Avoid ad-hoc Marionette logging setup. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 06 Jun 2018 14:38:36 +0100
changeset 808104 a1e2a8486516fb98ec14dd25a4f2f8d5b308fc71
parent 808099 374124504debed7ccbf40b17129156a0e48ca2bc
child 808105 5bf575a2ecec75f60a0e1af35ad7cbe25727761c
push id113277
push userbmo:ato@sny.no
push dateMon, 18 Jun 2018 12:24:24 +0000
reviewerswhimboo
bugs1464469
milestone62.0a1
Bug 1464469 - Avoid ad-hoc Marionette logging setup. r?whimboo By using the new log access functions we can avoid ad-hoc log setup in the Marionette component. This encapsulates the workarounds for dealing with lack of E10s support in Log.jsm to testing/marionette/log.js. Because the Marionette component is loaded at any time, we need to keep the lazy getter for accessing the logger. MozReview-Commit-ID: EabQ0zXSsGK
testing/marionette/components/marionette.js
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -8,26 +8,22 @@ ChromeUtils.import("resource://gre/modul
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const {
   EnvironmentPrefs,
   MarionettePrefs,
 } = ChromeUtils.import("chrome://marionette/content/prefs.js", {});
 
 XPCOMUtils.defineLazyModuleGetters(this, {
-  Log: "resource://gre/modules/Log.jsm",
+  Log: "chrome://marionette/content/log.js",
   Preferences: "resource://gre/modules/Preferences.jsm",
   TCPListener: "chrome://marionette/content/server.js",
 });
 
-XPCOMUtils.defineLazyGetter(this, "log", () => {
-  let log = Log.repository.getLogger("Marionette");
-  log.addAppender(new Log.DumpAppender());
-  return log;
-});
+XPCOMUtils.defineLazyGetter(this, "log", Log.get);
 
 XPCOMUtils.defineLazyServiceGetter(
     this, "env", "@mozilla.org/process/environment;1", "nsIEnvironment");
 
 const NOTIFY_RUNNING = "remote-active";
 
 // Complements -marionette flag for starting the Marionette server.
 // We also set this if Marionette is running in order to start the server
@@ -279,19 +275,16 @@ class MarionetteParentProcess {
     // holds reference to ChromeWindow
     // used to run GFX sanity tests on Windows
     this.gfxWindow = null;
 
     // indicates that all pending window checks have been completed
     // and that we are ready to start the Marionette server
     this.finalUIStartup = false;
 
-    log.level = MarionettePrefs.logLevel;
-    Services.ppmm.initialProcessData["Marionette:Log"] = {level: log.level};
-
     this.enabled = env.exists(ENV_ENABLED);
     this.alteredPrefs = new Set();
 
     Services.prefs.addObserver(PREF_ENABLED, this);
     Services.ppmm.addMessageListener("Marionette:IsRunning", this);
   }
 
   get running() {