Bug 1702142 - [remote] Unify logging between Marionette and Remote Agent. r=remote-protocol-reviewers,jgraham

Differential Revision: https://phabricator.services.mozilla.com/D110936
This commit is contained in:
Henrik Skupin 2021-04-06 15:08:50 +00:00
Родитель 91a2eec7e9
Коммит 10ed8516d0
4 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@ -16,7 +16,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
UnknownMethodError: "chrome://remote/content/cdp/Error.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get());
XPCOMUtils.defineLazyServiceGetter(
this,
@ -65,7 +65,7 @@ class Connection {
send(body) {
const payload = JSON.stringify(body, null, Log.verbose ? "\t" : null);
log.trace(truncate`<-(connection ${this.id}) ${payload}`);
logger.trace(truncate`<-(connection ${this.id}) ${payload}`);
this.transport.send(JSON.parse(payload));
}
@ -186,7 +186,7 @@ class Connection {
* JSON-serializable object sent by the client
*/
async onPacket(packet) {
log.trace(`(connection ${this.id})-> ${JSON.stringify(packet)}`);
logger.trace(`(connection ${this.id})-> ${JSON.stringify(packet)}`);
try {
const { id, method, params, sessionId } = packet;

Просмотреть файл

@ -21,7 +21,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
Log: "chrome://remote/content/shared/Log.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get());
class RemoteAgentError extends Error {
constructor(message = "", cause = undefined) {
@ -37,7 +37,7 @@ class RemoteAgentError extends Error {
notify() {
Cu.reportError(this);
log.error(this.toString({ stack: true }));
logger.error(this.toString({ stack: true }));
}
toString({ stack = false } = {}) {
@ -94,7 +94,7 @@ class FatalError extends RemoteAgentError {
}
notify() {
log.fatal(this.toString({ stack: true }));
logger.fatal(this.toString({ stack: true }));
}
quit(mode = Ci.nsIAppStartup.eForceQuit) {

Просмотреть файл

@ -21,7 +21,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
TargetList: "chrome://remote/content/cdp/targets/TargetList.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get());
const ENABLED = "remote.enabled";
const FORCE_LOCAL = "remote.force-local";
@ -82,7 +82,7 @@ class RemoteAgentClass {
for (let [k, v] of RecommendedPreferences) {
if (!Preferences.isSet(k)) {
log.debug(`Setting recommended pref ${k} to ${v}`);
logger.debug(`Setting recommended pref ${k} to ${v}`);
Preferences.set(k, v);
this.alteredPrefs.add(k);
}
@ -118,14 +118,14 @@ class RemoteAgentClass {
);
} catch (e) {
await this.close();
log.error(`Unable to start remote agent: ${e.message}`, e);
logger.error(`Unable to start remote agent: ${e.message}`, e);
}
}
close() {
try {
for (let k of this.alteredPrefs) {
log.debug(`Resetting recommended pref ${k}`);
logger.debug(`Resetting recommended pref ${k}`);
Preferences.reset(k);
}
this.alteredPrefs.clear();
@ -141,7 +141,7 @@ class RemoteAgentClass {
}
} catch (e) {
// this function must never fail
log.error("unable to stop listener", e);
logger.error("unable to stop listener", e);
} finally {
this.server = null;
this.targetList = null;

Просмотреть файл

@ -16,7 +16,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
Log: "chrome://remote/content/shared/Log.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get());
const ELEMENT_NODE = 1;
const MAX_STRING_LENGTH = 250;
@ -101,7 +101,7 @@ function pprint(ss, ...values) {
try {
s = pretty(values[i]);
} catch (e) {
log.warn("Problem pretty printing:", e);
logger.warn("Problem pretty printing:", e);
s = typeof values[i];
}
res.push(s);