Add -zoterodebug command-line flag to force debug output
This should make it much easier to debug startup errors, particularly in Standalone. This also adds a general mechanism to set Zotero initialization options via command-line flags.
This commit is contained in:
parent
8e276b30d4
commit
6ff0ea6d18
3 changed files with 22 additions and 14 deletions
|
@ -27,8 +27,8 @@
|
|||
Zotero.Debug = new function () {
|
||||
var _console, _stackTrace, _store, _level, _time, _lastTime, _output = [];
|
||||
|
||||
this.init = function () {
|
||||
_console = Zotero.Prefs.get('debug.log');
|
||||
this.init = function (forceDebugLog) {
|
||||
_console = forceDebugLog || Zotero.Prefs.get('debug.log');
|
||||
_store = Zotero.Prefs.get('debug.store');
|
||||
if (_store) {
|
||||
Zotero.Prefs.set('debug.store', false);
|
||||
|
|
|
@ -218,14 +218,18 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
/**
|
||||
* Initialize the extension
|
||||
*/
|
||||
function init() {
|
||||
function init(options) {
|
||||
if (this.initialized || this.skipLoading) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load in the preferences branch for the extension
|
||||
Zotero.Prefs.init();
|
||||
Zotero.Debug.init();
|
||||
Zotero.Debug.init(options && options.forceDebugLog);
|
||||
|
||||
if (options) {
|
||||
if (options.openPane) this.openPane = true;
|
||||
}
|
||||
|
||||
this.mainThread = Components.classes["@mozilla.org/thread-manager;1"].getService().mainThread;
|
||||
|
||||
|
|
|
@ -125,6 +125,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
var instanceID = (new Date()).getTime();
|
||||
var isFirstLoadThisSession = true;
|
||||
var zContext = null;
|
||||
var zInitOptions = {};
|
||||
|
||||
ZoteroContext = function() {}
|
||||
ZoteroContext.prototype = {
|
||||
|
@ -169,7 +170,7 @@ ZoteroContext.prototype = {
|
|||
zContext.Zotero.shutdown().then(function() {
|
||||
// create a new zContext
|
||||
makeZoteroContext(isConnector);
|
||||
zContext.Zotero.init();
|
||||
zContext.Zotero.init(zInitOptions);
|
||||
}).done();
|
||||
}
|
||||
|
||||
|
@ -292,12 +293,12 @@ function ZoteroService() {
|
|||
if(isFirstLoadThisSession) {
|
||||
makeZoteroContext(false);
|
||||
try {
|
||||
zContext.Zotero.init();
|
||||
zContext.Zotero.init(zInitOptions);
|
||||
} catch(e) {
|
||||
// if Zotero should start as a connector, reload it
|
||||
zContext.Zotero.shutdown().then(function() {
|
||||
makeZoteroContext(true);
|
||||
zContext.Zotero.init();
|
||||
zContext.Zotero.init(zInitOptions);
|
||||
}).done();
|
||||
}
|
||||
}
|
||||
|
@ -341,6 +342,16 @@ function ZoteroCommandLineHandler() {}
|
|||
ZoteroCommandLineHandler.prototype = {
|
||||
/* nsICommandLineHandler */
|
||||
handle : function(cmdLine) {
|
||||
// Force debug output
|
||||
if (cmdLine.handleFlag("zoterodebug", false)) {
|
||||
zInitOptions.forceDebugLog = true;
|
||||
}
|
||||
|
||||
// handler to open Zotero pane at startup in Zotero for Firefox
|
||||
if (!isStandalone() && cmdLine.handleFlag("ZoteroPaneOpen", false)) {
|
||||
zInitOptions.openPane = true;
|
||||
}
|
||||
|
||||
// handler for Zotero integration commands
|
||||
// this is typically used on Windows only, via WM_COPYDATA rather than the command line
|
||||
var agent = cmdLine.handleFlagWithParam("ZoteroIntegrationAgent", false);
|
||||
|
@ -415,13 +426,6 @@ ZoteroCommandLineHandler.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
// handler to open Zotero pane at startup in Zotero for Firefox
|
||||
else {
|
||||
var zPaneOpen = cmdLine.handleFlag("ZoteroPaneOpen", false);
|
||||
if (zPaneOpen) {
|
||||
this.Zotero.openPane = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=zotero",
|
||||
|
|
Loading…
Add table
Reference in a new issue