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:
Dan Stillman 2013-11-30 01:55:48 -05:00
parent 8e276b30d4
commit 6ff0ea6d18
3 changed files with 22 additions and 14 deletions

View file

@ -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",