Skip to content

Commit

Permalink
Bug 1702142 - [remote] Unify logging between Marionette and Remote Ag…
Browse files Browse the repository at this point in the history
…ent. r=remote-protocol-reviewers,jgraham

Differential Revision: https://phabricator.services.mozilla.com/D110936
  • Loading branch information
whimboo committed Apr 6, 2021
1 parent 1d80fc1 commit aada131
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions remote/cdp/Connection.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions remote/cdp/Error.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 } = {}) {
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions remote/components/RemoteAgent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions remote/shared/Format.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit aada131

Please sign in to comment.