diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-02-08 13:41:36 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2011-02-08 13:42:19 -0700 |
commit | 3539c9474a0b53f57e614544c70a7197ecdfb130 (patch) | |
tree | 9c89416a0bdd10417af836fd02dbada2be2a381d /lib/bb | |
parent | d93fcbd64ab5d806288424170f55323b4297e7d6 (diff) | |
download | bitbake-3539c9474a0b53f57e614544c70a7197ecdfb130.tar.gz |
Shift traceback pre-formatting into LogHandler
It's cleaner to leave it behaving as usual, passing the exception data in the
exc_info attribute of the LogRecord where it normally lies, and then let
LogHandler make it pickleable so it can be sent to the UI.
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb')
-rw-r--r-- | lib/bb/__init__.py | 5 | ||||
-rw-r--r-- | lib/bb/event.py | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py index 572d5b31c..704511089 100644 --- a/lib/bb/__init__.py +++ b/lib/bb/__init__.py @@ -29,7 +29,7 @@ if sys.version_info < (2, 6, 0): import os import logging -import traceback + class NullHandler(logging.Handler): def emit(self, record): @@ -51,9 +51,6 @@ class BBLogger(Logger): def verbose(self, msg, *args, **kwargs): return self.log(logging.INFO - 1, msg, *args, **kwargs) - def exception(self, msg, *args, **kwargs): - return self.critical("%s\n%s" % (msg, traceback.format_exc()), *args, **kwargs) - logging.raiseExceptions = False logging.setLoggerClass(BBLogger) diff --git a/lib/bb/event.py b/lib/bb/event.py index c22a5910b..e76a82a93 100644 --- a/lib/bb/event.py +++ b/lib/bb/event.py @@ -30,6 +30,7 @@ except ImportError: import pickle import logging import atexit +import traceback import bb.utils # This is the pid for which we should generate the event. This is set when @@ -379,6 +380,9 @@ class LogHandler(logging.Handler): """Dispatch logging messages as bitbake events""" def emit(self, record): + if record.exc_info: + record.msg += '\n%s' % traceback.format_exception(*record.exc_info) + record.exc_info = None fire(record, None) def filter(self, record): |