summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-01-13 17:01:49 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-15 10:06:22 +0000
commiteb6291b36fd9206aec0476852042a18113039317 (patch)
tree9622c21183d5c34ee1aaed441d544dbc051606e1 /bitbake
parentecdfc1ebbe260fc7b2842b751d913580d294cb42 (diff)
downloadpoky-eb6291b36fd9206aec0476852042a18113039317.tar.gz
bitbake/knotty: avoid printing full task log when error already printed
If a task has logged an ERROR then don't print the contents of the task's log file in knotty (the default terminal UI). As a side-effect we now also respect BBINCLUDELOGS in knotty; if it is false we never print the log (but the pointer to the log file is always printed). (Bitbake rev: b9746b7e4d7aa5c34eba15a61427bfc6949af123) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/build.py18
-rw-r--r--bitbake/lib/bb/ui/knotty.py2
2 files changed, 16 insertions, 4 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 30e5497d1d..1e041a2a3e 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -91,8 +91,9 @@ class TaskSucceeded(TaskBase):
91class TaskFailed(TaskBase): 91class TaskFailed(TaskBase):
92 """Task execution failed""" 92 """Task execution failed"""
93 93
94 def __init__(self, task, logfile, metadata): 94 def __init__(self, task, logfile, metadata, errprinted = False):
95 self.logfile = logfile 95 self.logfile = logfile
96 self.errprinted = errprinted
96 super(TaskFailed, self).__init__(task, metadata) 97 super(TaskFailed, self).__init__(task, metadata)
97 98
98class TaskInvalid(TaskBase): 99class TaskInvalid(TaskBase):
@@ -286,6 +287,13 @@ def _exec_task(fn, task, d, quieterr):
286 prefuncs = localdata.getVarFlag(task, 'prefuncs', expand=True) 287 prefuncs = localdata.getVarFlag(task, 'prefuncs', expand=True)
287 postfuncs = localdata.getVarFlag(task, 'postfuncs', expand=True) 288 postfuncs = localdata.getVarFlag(task, 'postfuncs', expand=True)
288 289
290 class ErrorCheckHandler(logging.Handler):
291 def __init__(self):
292 self.triggered = False
293 logging.Handler.__init__(self, logging.ERROR)
294 def emit(self, record):
295 self.triggered = True
296
289 # Handle logfiles 297 # Handle logfiles
290 si = file('/dev/null', 'r') 298 si = file('/dev/null', 'r')
291 try: 299 try:
@@ -311,6 +319,9 @@ def _exec_task(fn, task, d, quieterr):
311 handler.setLevel(logging.DEBUG - 2) 319 handler.setLevel(logging.DEBUG - 2)
312 bblogger.addHandler(handler) 320 bblogger.addHandler(handler)
313 321
322 errchk = ErrorCheckHandler()
323 bblogger.addHandler(errchk)
324
314 localdata.setVar('BB_LOGFILE', logfn) 325 localdata.setVar('BB_LOGFILE', logfn)
315 326
316 event.fire(TaskStarted(task, localdata), localdata) 327 event.fire(TaskStarted(task, localdata), localdata)
@@ -322,8 +333,9 @@ def _exec_task(fn, task, d, quieterr):
322 exec_func(func, localdata) 333 exec_func(func, localdata)
323 except FuncFailed as exc: 334 except FuncFailed as exc:
324 if not quieterr: 335 if not quieterr:
336 errprinted = errchk.triggered
325 logger.error(str(exc)) 337 logger.error(str(exc))
326 event.fire(TaskFailed(task, logfn, localdata), localdata) 338 event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata)
327 return 1 339 return 1
328 finally: 340 finally:
329 sys.stdout.flush() 341 sys.stdout.flush()
@@ -366,7 +378,7 @@ def exec_task(fn, task, d):
366 if not quieterr: 378 if not quieterr:
367 logger.error("Build of %s failed" % (task)) 379 logger.error("Build of %s failed" % (task))
368 logger.error(format_exc()) 380 logger.error(format_exc())
369 failedevent = TaskFailed(task, None, d) 381 failedevent = TaskFailed(task, None, d, True)
370 event.fire(failedevent, d) 382 event.fire(failedevent, d)
371 return 1 383 return 1
372 384
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 5366386b20..205a8d8f39 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -142,7 +142,7 @@ def main(server, eventHandler):
142 logfile = event.logfile 142 logfile = event.logfile
143 if logfile and os.path.exists(logfile): 143 if logfile and os.path.exists(logfile):
144 print("ERROR: Logfile of failure stored in: %s" % logfile) 144 print("ERROR: Logfile of failure stored in: %s" % logfile)
145 if 1 or includelogs: 145 if includelogs and not event.errprinted:
146 print("Log data follows:") 146 print("Log data follows:")
147 f = open(logfile, "r") 147 f = open(logfile, "r")
148 lines = [] 148 lines = []