зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1482829 - Track Marionette logger verbosity with Log#manageLevelFromPref. r=whimboo
This patch adopts Logger#managerLevelFromPref from Log.jsm to set and keep track of the Marionette logger's verbosity. This has the advantage that we do not have to roll separate implementations of Log for the child- and parent processes. It also has the upside that the log level will be reflected when changed at runtime through the use of an observer.
This commit is contained in:
Родитель
658ee95d04
Коммит
719b4c5e30
|
@ -396,7 +396,7 @@ class RefTest(object):
|
|||
|
||||
# Enable tracing output for detailed failures in case of
|
||||
# failing connection attempts, and hangs (bug 1397201)
|
||||
prefs["marionette.log.level"] = "TRACE"
|
||||
prefs["marionette.log.level"] = "Trace"
|
||||
|
||||
# Third, set preferences passed in via the command line.
|
||||
for v in options.extraPrefs:
|
||||
|
|
|
@ -347,7 +347,7 @@ it will be removed once the interactability checks have been stabilized.
|
|||
<code>info</code>, <code>warn</code>,
|
||||
<code>error</code>, and <code>fatal</code>.
|
||||
If left undefined the default is <code>info</code>.
|
||||
The value is treated case-insensitively.
|
||||
The value is case-insensitive.
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ class GeckoInstance(object):
|
|||
args["preferences"].update(self.prefs)
|
||||
|
||||
if self.verbose:
|
||||
level = "TRACE" if self.verbose >= 2 else "DEBUG"
|
||||
level = "Trace" if self.verbose >= 2 else "Debug"
|
||||
args["preferences"]["marionette.log.level"] = level
|
||||
args["preferences"]["marionette.logging"] = level
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ Sets the verbosity level of the Marionette logger repository. Note
|
|||
that this preference does not control the verbosity of other loggers
|
||||
used in Firefox or Fennec.
|
||||
|
||||
The available levels are, in descending order of severity, `trace`,
|
||||
The available levels are, in descending order of severity, `Trace`,
|
||||
`debug`, `config`, `info`, `warn`, `error`, and `fatal`. The value
|
||||
is treated case-insensitively.
|
||||
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const StdLog = ChromeUtils.import("resource://gre/modules/Log.jsm", {}).Log;
|
||||
|
||||
const {MarionettePrefs} = ChromeUtils.import("chrome://marionette/content/prefs.js", {});
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["Log"];
|
||||
|
||||
const isChildProcess = Services.appinfo.processType ==
|
||||
Services.appinfo.PROCESS_TYPE_CONTENT;
|
||||
const PREF_LOG_LEVEL = "marionette.log.level";
|
||||
|
||||
/**
|
||||
* Shorthand for accessing the Marionette logging repository.
|
||||
|
@ -22,12 +18,9 @@ const isChildProcess = Services.appinfo.processType ==
|
|||
* appropriate stdout dumper and with the correct log level.
|
||||
*
|
||||
* Unlike `Log.jsm` this logger is E10s safe, meaning repository
|
||||
* configuration for appenders and logging levels are communicated
|
||||
* across processes.
|
||||
*
|
||||
* @name Log
|
||||
* configuration is communicated across processes.
|
||||
*/
|
||||
class MarionetteLog {
|
||||
class Log {
|
||||
/**
|
||||
* Obtain the `Marionette` logger.
|
||||
*
|
||||
|
@ -40,8 +33,8 @@ class MarionetteLog {
|
|||
let logger = StdLog.repository.getLogger("Marionette");
|
||||
if (logger.ownAppenders.length == 0) {
|
||||
logger.addAppender(new StdLog.DumpAppender());
|
||||
logger.manageLevelFromPref(PREF_LOG_LEVEL);
|
||||
}
|
||||
logger.level = MarionettePrefs.logLevel;
|
||||
return logger;
|
||||
}
|
||||
|
||||
|
@ -50,7 +43,7 @@ class MarionetteLog {
|
|||
*
|
||||
* Unlike {@link LoggerRepository.getLoggerWithMessagePrefix()}
|
||||
* this function will ensure invoke {@link #get()} first to ensure
|
||||
* the logger has been properly set up first.
|
||||
* the logger has been properly set up.
|
||||
*
|
||||
* This returns a new object with a prototype chain that chains
|
||||
* up the original {@link Logger} instance. The new prototype has
|
||||
|
@ -67,28 +60,4 @@ class MarionetteLog {
|
|||
}
|
||||
}
|
||||
|
||||
class ParentProcessLog extends MarionetteLog {
|
||||
static get() {
|
||||
let logger = super.get();
|
||||
Services.ppmm.initialProcessData["Marionette:Log"] = {level: logger.level};
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
class ChildProcessLog extends MarionetteLog {
|
||||
static get() {
|
||||
let logger = super.get();
|
||||
|
||||
// Log.jsm is not e10s compatible (see https://bugzil.la/1411513)
|
||||
// so loading it in a new child process will reset the repository config
|
||||
logger.level = Services.cpmm.initialProcessData["Marionette:Log"] || StdLog.Level.Info;
|
||||
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
if (isChildProcess) {
|
||||
this.Log = ChildProcessLog;
|
||||
} else {
|
||||
this.Log = ParentProcessLog;
|
||||
}
|
||||
this.Log = Log;
|
||||
|
|
|
@ -188,6 +188,8 @@ class MarionetteBranch extends Branch {
|
|||
* @return {Log.Level}
|
||||
*/
|
||||
get logLevel() {
|
||||
// TODO: when geckodriver's minimum supported Firefox version reaches 62,
|
||||
// the lower-casing here can be dropped (https://bugzil.la/1482829)
|
||||
switch (this.get("log.level", "info").toLowerCase()) {
|
||||
case "fatal":
|
||||
return Log.Level.Fatal;
|
||||
|
|
|
@ -19,7 +19,7 @@ pref("marionette.debugging.clicktostart", false);
|
|||
// Available levels are, in descending order of severity,
|
||||
// "trace", "debug", "config", "info", "warn", "error", and "fatal".
|
||||
// The value is treated case-insensitively.
|
||||
pref("marionette.log.level", "info");
|
||||
pref("marionette.log.level", "Info");
|
||||
|
||||
// Certain log messages that are known to be long are truncated
|
||||
// before they are dumped to stdout. The `marionette.log.truncate`
|
||||
|
|
|
@ -1909,7 +1909,7 @@ toolbar#nav-bar {
|
|||
"idle.lastDailyNotification": int(time.time()),
|
||||
# Enable tracing output for detailed failures in case of
|
||||
# failing connection attempts, and hangs (bug 1397201)
|
||||
"marionette.log.level": "TRACE",
|
||||
"marionette.log.level": "Trace",
|
||||
}
|
||||
|
||||
if options.flavor == 'browser' and options.timeout:
|
||||
|
|
Загрузка…
Ссылка в новой задаче