From c2bb4ac10b97865c4e13e32e8609035b09dc367a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 25 Jul 2017 02:36:33 -0400 Subject: [PATCH] Move debug output logging to the Help menu Adds a submenu for quickly generating and submitting debug output, with a button to copy the Debug ID to the clipboard and a one-click option to restart with logging enabled. Debug output can also now be viewed in real-time using the new debug output viewer window (previously available only via a command-line flag). The locale switcher has moved to the top of the Advanced prefpane (where Debug Output Logging used to go) in a Miscellaneous section, and there's a new "Advanced Configuration" section (mirroring Thunderbird) at the bottom for "Config Editor". Closes #1108 --- .../preferences/preferences_advanced.js | 197 ------------------ .../preferences/preferences_advanced.xul | 39 +--- .../content/zotero/standalone/standalone.js | 185 ++++++++++++++++ .../content/zotero/standalone/standalone.xul | 28 +++ chrome/content/zotero/xpcom/debug.js | 5 +- chrome/locale/en-US/zotero/preferences.dtd | 10 +- chrome/locale/en-US/zotero/standalone.dtd | 8 + chrome/locale/en-US/zotero/zotero.properties | 8 +- 8 files changed, 240 insertions(+), 240 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index 4fec46cc2..71d09c17d 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -30,7 +30,6 @@ Zotero_Preferences.Advanced = { init: function () { - Zotero_Preferences.Debug_Output.init(); Zotero_Preferences.Keys.init(); // Show Memory Info button if the Error Console menu option is enabled @@ -782,202 +781,6 @@ Zotero_Preferences.Attachment_Base_Directory = { }; -Zotero_Preferences.Debug_Output = { - _timer: null, - - init: function () { - var storing = Zotero.Debug.storing; - this._updateButton(); - this.updateLines(); - if (storing) { - this._initTimer(); - } - }, - - - toggleStore: function () { - this.setStore(!Zotero.Debug.storing); - }, - - - setStore: function (set) { - Zotero.Debug.setStore(set); - if (set) { - this._initTimer(); - } - else { - if (this._timerID) { - this._timer.cancel(); - this._timerID = null; - } - } - this._updateButton(); - this.updateLines(); - }, - - - view: function () { - Zotero_Preferences.openInViewer("zotero://debug/"); - }, - - - submit: Zotero.Promise.coroutine(function* () { - document.getElementById('debug-output-submit').disabled = true; - var pm = document.getElementById('debug-output-submit-progress'); - pm.hidden = false; - - Components.utils.import("resource://zotero/config.js"); - - var url = ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1"; - var output = yield Zotero.Debug.get( - Zotero.Prefs.get('debug.store.submitSize'), - Zotero.Prefs.get('debug.store.submitLineLength') - ); - Zotero_Preferences.Debug_Output.setStore(false); - - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - try { - var xmlhttp = yield Zotero.HTTP.request( - "POST", - url, - { - compressBody: true, - body: output, - logBodyLength: 30, - timeout: 30000, - requestObserver: function (req) { - // Don't fail during tests, with fake XHR - if (!req.channel) { - return; - } - req.channel.notificationCallbacks = { - onProgress: function (request, context, progress, progressMax) { - pm.mode = 'determined'; - if (!pm.value || progress > pm.value) { - pm.value = progress; - } - if (!pm.max || progressMax > pm.max) { - pm.max = progressMax; - } - }, - - // nsIInterfaceRequestor - getInterface: function (iid) { - try { - return this.QueryInterface(iid); - } - catch (e) { - throw Components.results.NS_NOINTERFACE; - } - }, - - QueryInterface: function(iid) { - if (iid.equals(Components.interfaces.nsISupports) || - iid.equals(Components.interfaces.nsIInterfaceRequestor) || - iid.equals(Components.interfaces.nsIProgressEventSink)) { - return this; - } - throw Components.results.NS_NOINTERFACE; - }, - - } - } - } - ); - } - catch (e) { - Zotero.logError(e); - let title = Zotero.getString('general.error'); - let msg; - if (e instanceof Zotero.HTTP.UnexpectedStatusException) { - msg = Zotero.getString('general.invalidResponseServer'); - } - else if (e instanceof Zotero.HTTP.BrowserOfflineException) { - msg = Zotero.getString('general.browserIsOffline', Zotero.appName); - } - else { - msg = Zotero.getString('zotero.preferences.advanced.debug.error'); - } - ps.alert(null, title, msg); - return false; - } - - document.getElementById('debug-output-submit').disabled = false; - document.getElementById('debug-output-submit-progress').hidden = true; - - Zotero.debug(xmlhttp.responseText); - - var reported = xmlhttp.responseXML.getElementsByTagName('reported'); - if (reported.length != 1) { - ps.alert( - null, - Zotero.getString('general.error'), - Zotero.getString('general.serverError') - ); - return false; - } - - var reportID = reported[0].getAttribute('reportID'); - ps.alert( - null, - Zotero.getString('zotero.preferences.advanced.debug.title'), - Zotero.getString('zotero.preferences.advanced.debug.sent', reportID) - ); - - return true; - }), - - - clear: function () { - Zotero.Debug.clear(); - this.updateLines(); - }, - - - updateLines: function () { - var enabled = Zotero.Debug.storing; - var lines = Zotero.Debug.count(); - document.getElementById('debug-output-lines').value = lines; - var empty = lines == 0; - document.getElementById('debug-output-view').disabled = !enabled && empty; - document.getElementById('debug-output-clear').disabled = empty; - document.getElementById('debug-output-submit').disabled = empty; - }, - - - _initTimer: function () { - this._timer = Components.classes["@mozilla.org/timer;1"]. - createInstance(Components.interfaces.nsITimer); - this._timer.initWithCallback({ - notify: function() { - Zotero_Preferences.Debug_Output.updateLines(); - } - }, 10000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK); - }, - - - _updateButton: function () { - var storing = Zotero.Debug.storing - - var button = document.getElementById('debug-output-enable'); - if (storing) { - button.label = Zotero.getString('general.disable'); - } - else { - button.label = Zotero.getString('general.enable'); - } - }, - - - onUnload: function () { - if (this._timer) { - this._timer.cancel(); - } - } -}; - - Zotero_Preferences.Keys = { init: function () { var rows = document.getElementById('zotero-prefpane-advanced-keys-tab').getElementsByTagName('row'); diff --git a/chrome/content/zotero/preferences/preferences_advanced.xul b/chrome/content/zotero/preferences/preferences_advanced.xul index 73dd1bb95..3f014e517 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.xul +++ b/chrome/content/zotero/preferences/preferences_advanced.xul @@ -71,26 +71,15 @@ - - - - - - &zotero.preferences.debugOutputLogging.message; - + + -