From 9550b49921e4ad09b53c506db637ca9bf8b0fa57 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 29 Aug 2013 14:01:04 -0500 Subject: [PATCH] Add exception hook --- teuthology/run.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/teuthology/run.py b/teuthology/run.py index f3e44abae9f25..1baa627748bbe 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -4,6 +4,9 @@ import yaml import StringIO import contextlib import logging +import sys +from traceback import format_tb + def config_file(string): config = {} @@ -103,6 +106,17 @@ def set_up_logging(ctx): handler.setFormatter(formatter) logging.getLogger().addHandler(handler) + install_except_hook() + + +def install_except_hook(): + def log_exception(exception_class, exception, traceback): + logging.critical(''.join(format_tb(traceback))) + logging.critical('{0}: {1}'.format(exception_class, exception)) + + sys.excepthook = log_exception + + def write_initial_metadata(ctx): if ctx.archive is not None: with file(os.path.join(ctx.archive, 'pid'), 'w') as f: -- 2.39.5