Permalink
Browse files

Add restart with debug level logging (PR #6721)

Fixes #6689

- An option has been added to the exit dialog to restart with debug level logging. This provides a convenience to users who wish to enable debug level logging temporarily (one run of nvda).
- A start up command line argument (`--debug-logging`) has been 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...
1 parent b4e99f0 commit a2ac3dad7c5ead5c7f3d2bfb6929bf1e3606b535 @feerrenrut feerrenrut committed on GitHub Jan 31, 2017
Showing with 23 additions and 4 deletions.
  1. +4 −0 readme.md
  2. +7 −1 source/core.py
  3. +6 −2 source/gui/__init__.py
  4. +1 −1 source/logHandler.py
  5. +4 −0 source/nvda.pyw
  6. +1 −0 user_docs/en/userGuide.t2t
View
@@ -126,6 +126,10 @@ Please see the release keyword argument for what compiler optimizations it will
## Running the Source Code
To start NVDA from source code, run `nvda.pyw` located in the source directory.
+To view help on the arguments that NVDA will accept, use the `-h` or `--help` option.
+These arguments are also documented in the user guide.
+Since NVDA is a Windows application (rather than command line), it is best to run it with `pythonw.exe`.
+However, if during development you encounter an error early in the startup of NVDA, you can use `python.exe` which is likely to give more information about the error.
## Building NVDA
A binary build of NVDA can be run on a system without Python and all of NVDA's other dependencies installed (as we do for snapshots and releases).
View
@@ -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
@@ -79,8 +79,14 @@ def restart(disableAddons=False):
sys.argv.remove('--disable-addons')
except ValueError:
pass
+ try:
+ sys.argv.remove('--debug-logging')
+ except ValueError:
+ pass
if disableAddons:
options.append('--disable-addons')
+ if debugLogging:
+ options.append('--debug-logging')
try:
sys.argv.remove("--ease-of-access")
except ValueError:
@@ -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)
@@ -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):
@@ -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
View
@@ -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).")
@@ -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
@@ -2298,6 +2298,7 @@ Following are the command line options for NVDA:
| -m | --minimal | No sounds, no interface, no start message etc |
| -s | --secure | Secure mode (disable Python console) |
| None | --disable-addons | Addons will have no effect |
+| None | --debug-logging | Enable debug level logging just for this run. This setting will override any other log level ( ""--loglevel"", -l) argument given. |
| None | --no-sr-flag | Don't change the global system screen reader flag |
| None | --install | Installs NVDA (starting the newly installed copy) |
| None | --install-silent | Silently installs NVDA (does not start the newly installed copy) |

0 comments on commit a2ac3da

Please sign in to comment.