Bug 1152116 - prevent Sync from spamming the browser console. r=rnewman

This commit is contained in:
Mark Hammond 2015-05-18 17:34:22 +10:00
parent 3b4ee9fb65
commit adebd0ef35
5 changed files with 19 additions and 8 deletions

View File

@ -293,7 +293,11 @@ InternalScheduler.prototype = {
// the last success.
prefs.set("lastSync", new Date().toString());
this.state = this.STATE_OK;
this._logManager.resetFileLog();
this._logManager.resetFileLog().then(result => {
if (result == this._logManager.ERROR_LOG_WRITTEN) {
Cu.reportError("Reading List sync encountered an error - see about:sync-log for the log file.");
}
});
Services.obs.notifyObservers(null, "readinglist:sync:finish", null);
this._currentErrorBackoff = 0; // error retry interval is reset on success.
return intervals.schedule;
@ -307,7 +311,11 @@ InternalScheduler.prototype = {
this._currentErrorBackoff = 0; // error retry interval is reset on success.
this.log.info("Can't sync due to FxA account state " + err.message);
this.state = this.STATE_OK;
this._logManager.resetFileLog();
this._logManager.resetFileLog().then(result => {
if (result == this._logManager.ERROR_LOG_WRITTEN) {
Cu.reportError("Reading List sync encountered an error - see about:sync-log for the log file.");
}
});
Services.obs.notifyObservers(null, "readinglist:sync:finish", null);
// it's unfortunate that we are probably going to hit this every
// 2 hours, but it should be invisible to the user.

View File

@ -184,7 +184,7 @@ LogManager.prototype = {
return observer;
}
this._observeConsolePref = setupAppender(consoleAppender, "log.appender.console", Log.Level.Error, true);
this._observeConsolePref = setupAppender(consoleAppender, "log.appender.console", Log.Level.Fatal, true);
this._observeDumpPref = setupAppender(dumpAppender, "log.appender.dump", Log.Level.Error, true);
// The file appender doesn't get the special singleton behaviour.

View File

@ -30,8 +30,8 @@ add_task(function* test_noPrefs() {
let log = Log.repository.getLogger("TestLog");
let [capp, dapp, fapps] = getAppenders(log);
// the "dump" and "console" appenders should get Error level
equal(capp.level, Log.Level.Error);
// The console appender gets "Fatal" while the "dump" appender gets "Error" levels
equal(capp.level, Log.Level.Fatal);
equal(dapp.level, Log.Level.Error);
// and the file (stream) appender gets Debug by default
equal(fapps.length, 1, "only 1 file appender");
@ -62,7 +62,7 @@ add_task(function* test_PrefChanges() {
Services.prefs.setCharPref("log-manager.test.log.appender.console", "xxx");
Services.prefs.setCharPref("log-manager.test.log.appender.dump", "xxx");
Services.prefs.setCharPref("log-manager.test.log.appender.file.level", "xxx");
equal(capp.level, Log.Level.Error);
equal(capp.level, Log.Level.Fatal);
equal(dapp.level, Log.Level.Error);
equal(fapp.level, Log.Level.Debug);
lm.finalize();

View File

@ -685,9 +685,12 @@ ErrorHandler.prototype = {
* and refresh the input & output streams.
*/
resetFileLog: function resetFileLog() {
let onComplete = () => {
let onComplete = logType => {
Svc.Obs.notify("weave:service:reset-file-log");
this._log.trace("Notified: " + Date.now());
if (logType == this._logManager.ERROR_LOG_WRITTEN) {
Cu.reportError("Sync encountered an error - see about:sync-log for the log file.");
}
};
// Note we do not return the promise here - the caller doesn't need to wait
// for this to complete.

View File

@ -54,7 +54,7 @@ pref("services.sync.addons.ignoreUserEnabledChanges", false);
// Comma-delimited list of hostnames to trust for add-on install.
pref("services.sync.addons.trustedSourceHostnames", "addons.mozilla.org");
pref("services.sync.log.appender.console", "Warn");
pref("services.sync.log.appender.console", "Fatal");
pref("services.sync.log.appender.dump", "Error");
pref("services.sync.log.appender.file.level", "Trace");
pref("services.sync.log.appender.file.logOnError", true);