From 5e3b42f79047622aa8fbc3f6fb69cda4525adb2c Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Thu, 17 Dec 2009 18:51:55 -0800 Subject: [PATCH] Bug 535722 - Reduce the amount of logging for default log levels Include the URI on success/fail requests and only trace log the onStartRequest. Switch various debug messages to trace and remove importing Log4Moz in fx-weave-overlay and generic-change. Drop the rootLogger to Debug to not log trace messages from unpreffed loggers. --- services/sync/modules/engines.js | 10 ++++---- services/sync/modules/resource.js | 39 ++++++++----------------------- services/sync/modules/service.js | 2 +- services/sync/modules/util.js | 2 +- services/sync/services-sync.js | 2 +- 5 files changed, 18 insertions(+), 37 deletions(-) diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index d48e975e44a8..8e79136f02f5 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -262,7 +262,7 @@ Engine.prototype = { return "Total (ms): " + sums.sort(order).join(", "); }; - this._log.info(stats); + this._log.debug(stats); } }, @@ -347,7 +347,7 @@ SyncEngine.prototype = { // Any setup that needs to happen at the beginning of each sync. // Makes sure crypto records and keys are all set-up _syncStartup: function SyncEngine__syncStartup() { - this._log.debug("Ensuring server crypto records are there"); + this._log.trace("Ensuring server crypto records are there"); // Try getting/unwrapping the crypto record let meta = CryptoMetas.get(this.cryptoMetaURL); @@ -391,7 +391,7 @@ SyncEngine.prototype = { // NOTE: we use a backdoor (of sorts) to the tracker so it // won't save to disk this list over and over if (!this.lastSync) { - this._log.info("First sync, uploading all items"); + this._log.debug("First sync, uploading all items"); this._tracker.clearChangedIDs(); [i for (i in this._store.getAllIDs())] .forEach(function(id) this._tracker.changedIDs[id] = true, this); @@ -406,7 +406,7 @@ SyncEngine.prototype = { // Generate outgoing records _processIncoming: function SyncEngine__processIncoming() { - this._log.debug("Downloading & applying server changes"); + this._log.trace("Downloading & applying server changes"); // Figure out how many total items to fetch this sync; do less on mobile let fetchNum = 1500; @@ -614,7 +614,7 @@ SyncEngine.prototype = { _uploadOutgoing: function SyncEngine__uploadOutgoing() { let outnum = [i for (i in this._tracker.changedIDs)].length; if (outnum) { - this._log.debug("Preparing " + outnum + " outgoing records"); + this._log.trace("Preparing " + outnum + " outgoing records"); // collection we'll upload let up = new Collection(this.engineURL); diff --git a/services/sync/modules/resource.js b/services/sync/modules/resource.js index 8346583e9270..f84804e2dc72 100644 --- a/services/sync/modules/resource.js +++ b/services/sync/modules/resource.js @@ -235,23 +235,15 @@ Resource.prototype = { status = channel.responseStatus; success = channel.requestSucceeded; - if (success) { - this._log.debug(action + " success: " + status); - if (this._log.level <= Log4Moz.Level.Trace) - this._log.trace(action + " Body: " + this._data); - } - else { - let log = "debug"; - let mesg = action + " fail: " + status; - - // Only log the full response body (may be HTML) when Trace logging - if (this._log.level <= Log4Moz.Level.Trace) { - log = "trace"; - mesg += " " + this._data; - } - - this._log[log](mesg); - } + // Log the status of the request + let mesg = [action, success ? "success" : "fail", status, + channel.URI.spec].join(" "); + if (mesg.length > 200) + mesg = mesg.substr(0, 200) + "…"; + this._log.debug(mesg); + // Additionally give the full response body when Trace logging + if (this._log.level <= Log4Moz.Level.Trace) + this._log.trace(action + " body: " + this._data); // this is a server-side safety valve to allow slowing down clients without hurting performance if (headers["X-Weave-Backoff"]) @@ -314,19 +306,8 @@ function ChannelListener(onComplete, onProgress, logger) { } ChannelListener.prototype = { onStartRequest: function Channel_onStartRequest(channel) { - // XXX Bug 482179 Some reason xpconnect makes |channel| only nsIRequest channel.QueryInterface(Ci.nsIHttpChannel); - - let log = "trace"; - let mesg = channel.requestMethod + " request for " + channel.URI.spec; - // Only log a part of the uri for logs higher than trace - if (this._log.level > Log4Moz.Level.Trace) { - log = "debug"; - if (mesg.length > 200) - mesg = mesg.substr(0, 200) + "..."; - } - this._log[log](mesg); - + this._log.trace(channel.requestMethod + " " + channel.URI.spec); this._data = ''; }, diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 67514d6c1f29..3dc6bb826b25 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -1023,7 +1023,7 @@ WeaveSvc.prototype = { return; } - this._log.debug("Next sync in " + Math.ceil(interval / 1000) + " sec."); + this._log.trace("Next sync in " + Math.ceil(interval / 1000) + " sec."); Utils.delay(function() this.syncOnIdle(), interval, this, "_syncTimer"); // Save the next sync time in-case sync is disabled (logout/offline/etc.) diff --git a/services/sync/modules/util.js b/services/sync/modules/util.js index 6c94b6f1584a..a9dcceeb3b54 100644 --- a/services/sync/modules/util.js +++ b/services/sync/modules/util.js @@ -104,7 +104,7 @@ let Utils = { let thisArg = this; let notify = function(state) { let mesg = prefix + name + ":" + state; - thisArg._log.debug("Event: " + mesg); + thisArg._log.trace("Event: " + mesg); Observers.notify(mesg, subject); }; diff --git a/services/sync/services-sync.js b/services/sync/services-sync.js index 70bc93034d28..9ce1764384fd 100644 --- a/services/sync/services-sync.js +++ b/services/sync/services-sync.js @@ -19,7 +19,7 @@ pref("extensions.weave.engine.tabs.filteredUrls", "^(about:blank|chrome://weave/ pref("extensions.weave.log.appender.console", "Warn"); pref("extensions.weave.log.appender.dump", "Error"); pref("extensions.weave.log.appender.debugLog", "Trace"); -pref("extensions.weave.log.rootLogger", "Trace"); +pref("extensions.weave.log.rootLogger", "Debug"); pref("extensions.weave.log.logger.service.main", "Debug"); pref("extensions.weave.log.logger.authenticator", "Debug"); pref("extensions.weave.log.logger.network.resources", "Debug");