summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-05-06 00:43:38 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-08 19:38:25 (GMT)
commit96e2ee1d730fa19665cca34c2cc3deb3fa5dfd2d (patch)
tree9c75b5c023be0bb02681d09cf42b1d4f358364c4 /bitbake
parenta3efbb96f23a222c58f2f4114a75d2f98d7da11f (diff)
downloadpoky-96e2ee1d730fa19665cca34c2cc3deb3fa5dfd2d.tar.gz
Shift exception formatting into the UI
Now we use bb.exceptions to pass pickleable traceback entries to the UI, and the UI is free to do whatever it wants to do with this information. By default, the log formatter for the UIs formats it with bb.exceptions. This also means that all exceptions should now show 3 lines of context and limit to 5 entries. (Bitbake rev: ee48d628ee038bd72e1cd94aa75f5ccbacbcee4c) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cooker.py10
-rw-r--r--bitbake/lib/bb/event.py7
-rw-r--r--bitbake/lib/bb/msg.py10
3 files changed, 19 insertions, 8 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index a15b81f..641a839 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1225,7 +1225,7 @@ class CookerParser(object):
1225 raise 1225 raise
1226 except ParsingFailure as exc: 1226 except ParsingFailure as exc:
1227 self.shutdown(clean=False) 1227 self.shutdown(clean=False)
1228 bb.fatal('Error parsing %s: %s' % 1228 bb.fatal('Unable to parse %s: %s' %
1229 (exc.recipe, bb.exceptions.to_string(exc.realexception))) 1229 (exc.recipe, bb.exceptions.to_string(exc.realexception)))
1230 except bb.parse.ParseError as exc: 1230 except bb.parse.ParseError as exc:
1231 bb.fatal(str(exc)) 1231 bb.fatal(str(exc))
@@ -1233,13 +1233,11 @@ class CookerParser(object):
1233 logger.error('Unable to parse %s', exc.recipe) 1233 logger.error('Unable to parse %s', exc.recipe)
1234 sys.exit(1) 1234 sys.exit(1)
1235 except Exception as exc: 1235 except Exception as exc:
1236 import traceback
1237 etype, value, tb = sys.exc_info() 1236 etype, value, tb = sys.exc_info()
1238 formatted = bb.exceptions.format_extracted(value.traceback, limit=5) 1237 logger.error('Unable to parse %s', value.recipe,
1239 formatted.extend(traceback.format_exception_only(etype, value)) 1238 exc_info=(etype, value, exc.traceback))
1240
1241 self.shutdown(clean=False) 1239 self.shutdown(clean=False)
1242 bb.fatal('Error parsing %s:\n%s' % (value.recipe, ''.join(formatted))) 1240 sys.exit(1)
1243 1241
1244 self.current += 1 1242 self.current += 1
1245 self.virtuals += len(result) 1243 self.virtuals += len(result)
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 4ff530f..a3288b6 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -30,6 +30,7 @@ except ImportError:
30 import pickle 30 import pickle
31import logging 31import logging
32import atexit 32import atexit
33import traceback
33import bb.utils 34import bb.utils
34 35
35# This is the pid for which we should generate the event. This is set when 36# This is the pid for which we should generate the event. This is set when
@@ -423,6 +424,12 @@ class LogHandler(logging.Handler):
423 """Dispatch logging messages as bitbake events""" 424 """Dispatch logging messages as bitbake events"""
424 425
425 def emit(self, record): 426 def emit(self, record):
427 if record.exc_info:
428 etype, value, tb = record.exc_info
429 if hasattr(tb, 'tb_next'):
430 tb = list(bb.exceptions.extract_traceback(tb, context=3))
431 record.bb_exc_info = (etype, value, tb)
432 record.exc_info = None
426 fire(record, None) 433 fire(record, None)
427 434
428 def filter(self, record): 435 def filter(self, record):
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index a7ac850..12d19ff 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -65,9 +65,15 @@ class BBLogFormatter(logging.Formatter):
65 def format(self, record): 65 def format(self, record):
66 record.levelname = self.getLevelName(record.levelno) 66 record.levelname = self.getLevelName(record.levelno)
67 if record.levelno == self.PLAIN: 67 if record.levelno == self.PLAIN:
68 return record.getMessage() 68 msg = record.getMessage()
69 else: 69 else:
70 return logging.Formatter.format(self, record) 70 msg = logging.Formatter.format(self, record)
71
72 if hasattr(record, 'bb_exc_info'):
73 etype, value, tb = record.bb_exc_info
74 formatted = bb.exceptions.format_exception(etype, value, tb, limit=5)
75 msg += '\n' + ''.join(formatted)
76 return msg
71 77
72class Loggers(dict): 78class Loggers(dict):
73 def __getitem__(self, key): 79 def __getitem__(self, key):