cli: Don't double print uncaught exceptions with --debug

We have an excepthook that logs uncaught exceptions for good
reason, but if printing --debug to stdout this exception gets
printed twice when we invoke the stock __excepthook__. Skip that
in the debug_stdout case.
This commit is contained in:
Cole Robinson 2018-03-16 17:48:17 -04:00
parent 2f0e730efc
commit 6969066b9f

View File

@ -256,7 +256,10 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
def exception_log(typ, val, tb):
logging.debug("Uncaught exception:\n%s",
"".join(traceback.format_exception(typ, val, tb)))
sys.__excepthook__(typ, val, tb)
if not debug_stdout:
# If we are already logging to stdout, don't double print
# the backtrace
sys.__excepthook__(typ, val, tb)
sys.excepthook = exception_log
logging.getLogger("requests").setLevel(logging.ERROR)