[bitbake-devel] [PATCH 1/2] lib/bb: provide mechanism to bypass UI log suppression

Paul Eggleton paul.eggleton at linux.intel.com
Tue Jul 14 14:26:41 UTC 2015


The recent change to connect through the shell logging functions had an
unexpected side-effect - bb.error() and bb.fatal() cause a flag to be
set internally such that BitBake's UI will not print the full task log
on failure; unfortunately we have in places within the OpenEmbedded
metadata called these shell logging functions under error situations
where we still want to see the full log (i.e., the message we're sending
doesn't include the full error). Thus, provide a mechanism to fatally
exit with an error but unset the flag, utilising the built-in python
logging functionality that allows extra values to be passed in the log
record.

Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
 lib/bb/__init__.py | 8 ++++----
 lib/bb/build.py    | 7 ++++++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py
index 1a30fa1..1f7946e 100644
--- a/lib/bb/__init__.py
+++ b/lib/bb/__init__.py
@@ -94,11 +94,11 @@ def note(*args):
 def warn(*args):
     logger.warn(''.join(args))
 
-def error(*args):
-    logger.error(''.join(args))
+def error(*args, **kwargs):
+    logger.error(''.join(args), extra=kwargs)
 
-def fatal(*args):
-    logger.critical(''.join(args))
+def fatal(*args, **kwargs):
+    logger.critical(''.join(args), extra=kwargs)
     raise BBHandledException()
 
 def deprecated(func, name=None, advice=""):
diff --git a/lib/bb/build.py b/lib/bb/build.py
index cce01fe..3439964 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -350,6 +350,8 @@ exit $?
                 # The caller will call exit themselves, so bb.error() is
                 # what we want here rather than bb.fatal()
                 bb.error(value)
+            elif cmd == 'bbfatal_log':
+                bb.error(value, forcelog=True)
             elif cmd == 'bbdebug':
                 splitval = value.split(' ', 1)
                 level = int(splitval[0])
@@ -446,7 +448,10 @@ def _exec_task(fn, task, d, quieterr):
             self.triggered = False
             logging.Handler.__init__(self, logging.ERROR)
         def emit(self, record):
-            self.triggered = True
+            if getattr(record, 'forcelog', False):
+                self.triggered = False
+            else:
+                self.triggered = True
 
     # Handle logfiles
     si = open('/dev/null', 'r')
-- 
2.1.0




More information about the bitbake-devel mailing list