Skip to content

Commit

Permalink
Add restart with debug level logging
Browse files Browse the repository at this point in the history
See issue #6689
This provides a convenience to users who wish to enable debug level
logging temporarily (one run of nvda).
A start up option is added to make it easier to start nvda with debug
level logging. Enabling debug logging in this way sets the log level
earlier than setting it via the configuration file. In particular, this
allows the debug messages that occur during the loading of the
configuration file to be present in the log file.
  • Loading branch information
feerrenrut committed Jan 11, 2017
1 parent 48b6d71 commit 6af0932
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion source/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def doStartupDialogs():
"More details about the errors can be found in the log file."),
_("gesture map File Error"), wx.OK|wx.ICON_EXCLAMATION)

def restart(disableAddons=False):
def restart(disableAddons=False, debugLogging=False):
"""Restarts NVDA by starting a new copy with -r."""
if globalVars.appArgs.launcher:
import wx
Expand All @@ -81,6 +81,8 @@ def restart(disableAddons=False):
pass
if disableAddons:
options.append('--disable-addons')
if debugLogging:
options.append('--debug-logging')
try:
sys.argv.remove("--ease-of-access")
except ValueError:
Expand Down
8 changes: 6 additions & 2 deletions source/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,9 @@ def __init__(self, parent):
# Translators: An option in the combo box to choose exit action.
_("Restart"),
# Translators: An option in the combo box to choose exit action.
_("Restart with add-ons disabled")]
_("Restart with add-ons disabled"),
# Translators: An option in the combo box to choose exit action.
_("Restart with debug logging enabled")]
self.actionsList = contentSizerHelper.addLabeledControl(labelText, wx.Choice, choices=self.actions)
self.actionsList.SetSelection(0)

Expand All @@ -763,7 +765,9 @@ def onOk(self, evt):
elif action == 1:
queueHandler.queueFunction(queueHandler.eventQueue,core.restart)
elif action == 2:
queueHandler.queueFunction(queueHandler.eventQueue,core.restart,True)
queueHandler.queueFunction(queueHandler.eventQueue,core.restart,disableAddons=True)
elif action == 3:
queueHandler.queueFunction(queueHandler.eventQueue,core.restart,debugLogging=True)
self.Destroy()

def onCancel(self, evt):
Expand Down
2 changes: 1 addition & 1 deletion source/logHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def initialize(shouldDoRemoteLogging=False):
def setLogLevelFromConfig():
"""Set the log level based on the current configuration.
"""
if globalVars.appArgs.logLevel != 0 or globalVars.appArgs.secure:
if globalVars.appArgs.debugLogging or globalVars.appArgs.logLevel != 0 or globalVars.appArgs.secure:
# Log level was overridden on the command line or we're running in secure mode,
# so don't set it.
return
Expand Down
4 changes: 4 additions & 0 deletions source/nvda.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ parser.add_option('-c','--config-path',dest='configPath',default=None,help="The
parser.add_option('-m','--minimal',action="store_true",dest='minimal',default=False,help="No sounds, no interface, no start message etc")
parser.add_option('-s','--secure',action="store_true",dest='secure',default=False,help="Secure mode (disable Python console)")
parser.add_option('--disable-addons',action="store_true",dest='disableAddons',default=False,help="Disable all add-ons")
parser.add_option('--debug-logging',action="store_true",dest='debugLogging',default=False,help="Enable debug level logging just for this run. This setting will override any other log level (--loglevel, -l) argument given.")
parser.add_option('--no-sr-flag',action="store_false",dest='changeScreenReaderFlag',default=True,help="Don't change the global system screen reader flag")
parser.add_option('--install',action="store_true",dest='install',default=False,help="Installs NVDA (starting the new copy after installation)")
parser.add_option('--install-silent',action="store_true",dest='installSilent',default=False,help="Installs NVDA silently (does not start the new copy after installation).")
Expand Down Expand Up @@ -168,10 +169,13 @@ if isSecureDesktop:
logLevel=globalVars.appArgs.logLevel
if logLevel<=0:
logLevel=log.INFO
if globalVars.appArgs.debugLogging:
logLevel=log.DEBUG
logHandler.initialize()
logHandler.log.setLevel(logLevel)

log.info("Starting NVDA")
log.debug("Debug level logging enabled")
if globalVars.appArgs.changeScreenReaderFlag:
winUser.setSystemScreenReaderFlag(True)
#Accept wm_quit from other processes, even if running with higher privilages
Expand Down

0 comments on commit 6af0932

Please sign in to comment.