always log a traceback in the sys.excepthook

oslo logging overwrites the system sys.excepthook. However, in
the default case it does so in a way that masks the actual exception.
This means that developing with oslo logging enabled is really
really frustrating, as python syntax errors are just randomly
swallowed and you are off to guessing.

Because it's taking over the system level excepthook, it needs to
not do the very unexpected thing and eat all the real information.

Change-Id: I8d03d4abd77453856191c48512b7a27a7773084b
This commit is contained in:
Sean Dague
2014-05-27 14:46:49 -04:00
parent 5d4d1f3191
commit bff8813f23

View File

@@ -423,9 +423,7 @@ class JSONFormatter(logging.Formatter):
def _create_logging_excepthook(product_name):
def logging_excepthook(exc_type, value, tb):
extra = {}
if CONF.verbose or CONF.debug:
extra['exc_info'] = (exc_type, value, tb)
extra = {'exc_info': (exc_type, value, tb)}
getLogger(product_name).critical(
"".join(traceback.format_exception_only(exc_type, value)),
**extra)