Bug 1251057 - enable debug logging for rest.js requests and responses. r=adw
authorMark Hammond <mhammond@skippinet.com.au>
Thu, 10 Mar 2016 17:20:29 +1100
changeset 325901 e36c64327f7af7ad8dbc9433d780cdd67e9e14a0
parent 325900 12637684d990bb6daa08fa7049f66af21c6706a5
child 325902 2e1a666a0c23397465b8c9e2fdcc846ca8ee13e4
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1251057
milestone48.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 1251057 - enable debug logging for rest.js requests and responses. r=adw
services/common/logmanager.js
services/common/rest.js
services/sync/modules/policies.js
--- a/services/common/logmanager.js
+++ b/services/common/logmanager.js
@@ -191,22 +191,16 @@ LogManager.prototype = {
     let fapp = this._fileAppender = new FlushableStorageAppender(formatter);
     // the stream gets a default of Debug as the user must go out of their way
     // to see the stuff spewed to it.
     this._observeStreamPref = setupAppender(fapp, "log.appender.file.level", Log.Level.Debug);
 
     // now attach the appenders to all our logs.
     for (let logName of logNames) {
       let log = Log.repository.getLogger(logName);
-      // Set all of the logs themselves to log all messages, and rely on the
-      // more restrictive levels on the appenders to restrict what is seen.
-      // (We possibly could find the smallest appender level and set the logs
-      // to that, but that gets tricky when we consider a singe log might end
-      // up being managed by multiple log managers - so this is fine for now.)
-      log.level = Log.Level.All;
       for (let appender of [fapp, dumpAppender, consoleAppender]) {
         log.addAppender(appender);
       }
     }
     // and use the first specified log as a "root" for our log.
     this._log = Log.repository.getLogger(logNames[0] + ".LogManager");
   },
 
--- a/services/common/rest.js
+++ b/services/common/rest.js
@@ -15,17 +15,17 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://services-common/utils.js");
 
 XPCOMUtils.defineLazyModuleGetter(this, "CryptoUtils",
                                   "resource://services-crypto/utils.js");
 
-const Prefs = new Preferences("services.common.rest.");
+const Prefs = new Preferences("services.common.");
 
 /**
  * Single use HTTP requests to RESTish resources.
  *
  * @param uri
  *        URI for the request. This can be an nsIURI object or a string
  *        that can be used to create one. An exception will be thrown if
  *        the string is not a valid URI.
@@ -311,16 +311,17 @@ RESTRequest.prototype = {
     // Create and initialize HTTP channel.
     let channel = NetUtil.newChannel({uri: this.uri, loadUsingSystemPrincipal: true})
                          .QueryInterface(Ci.nsIRequest)
                          .QueryInterface(Ci.nsIHttpChannel);
     this.channel = channel;
     channel.loadFlags |= this.loadFlags;
     channel.notificationCallbacks = this;
 
+    this._log.debug(`${method} request to ${this.uri.spec}`);
     // Set request headers.
     let headers = this._headers;
     for (let key in headers) {
       if (key == 'authorization') {
         this._log.trace("HTTP Header " + key + ": ***** (suppressed)");
       } else {
         this._log.trace("HTTP Header " + key + ": " + headers[key]);
       }
@@ -637,17 +638,17 @@ RESTRequest.prototype = {
  */
 this.RESTResponse = function RESTResponse() {
   this._log = Log.repository.getLogger(this._logName);
   this._log.level =
     Log.Level[Prefs.get("log.logger.rest.response")];
 }
 RESTResponse.prototype = {
 
-  _logName: "Sync.RESTResponse",
+  _logName: "Services.Common.RESTResponse",
 
   /**
    * Corresponding REST request
    */
   request: null,
 
   /**
    * HTTP status code
--- a/services/sync/modules/policies.js
+++ b/services/sync/modules/policies.js
@@ -556,17 +556,19 @@ ErrorHandler.prototype = {
   initLogs: function initLogs() {
     this._log = Log.repository.getLogger("Sync.ErrorHandler");
     this._log.level = Log.Level[Svc.Prefs.get("log.logger.service.main")];
 
     let root = Log.repository.getLogger("Sync");
     root.level = Log.Level[Svc.Prefs.get("log.rootLogger")];
 
     let logs = ["Sync", "FirefoxAccounts", "Hawk", "Common.TokenServerClient",
-                "Sync.SyncMigration", "browserwindow.syncui"];
+                "Sync.SyncMigration", "browserwindow.syncui",
+                "Services.Common.RESTRequest", "Services.Common.RESTRequest",
+               ];
 
     this._logManager = new LogManager(Svc.Prefs, logs, "sync");
   },
 
   observe: function observe(subject, topic, data) {
     this._log.trace("Handling " + topic);
     switch(topic) {
       case "weave:engine:sync:applied":