]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add exception hook
authorZack Cerza <zack@cerza.org>
Thu, 29 Aug 2013 19:01:04 +0000 (14:01 -0500)
committerZack Cerza <zack@cerza.org>
Thu, 29 Aug 2013 20:04:50 +0000 (15:04 -0500)
teuthology/run.py

index f3e44abae9f25e1953269c2fcf597638269805c5..1baa627748bbe9dc9f0fb374d58acfaf64f4260d 100644 (file)
@@ -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: