* [PATCH 0/1] lib/bb/build: enable access to logger within tasks
@ 2016-12-12 21:53 Paul Eggleton
2016-12-12 21:53 ` [PATCH 1/1] " Paul Eggleton
0 siblings, 1 reply; 2+ messages in thread
From: Paul Eggleton @ 2016-12-12 21:53 UTC (permalink / raw)
To: bitbake-devel
This patch is required to support the patch sent to OE-Core to fix
bbwarn/bberror also triggering log_check.
The following changes since commit b65a8193368ffa1d15af24a6acde8dce6bd4d383:
toaster: views Remove old code that converts template context to JSON (2016-12-12 20:44:47 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib paule/bb-logger-access
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/bb-logger-access
Paul Eggleton (1):
lib/bb/build: enable access to logger within tasks
lib/bb/build.py | 1 +
lib/bb/utils.py | 11 +++++++++++
2 files changed, 12 insertions(+)
--
2.5.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] lib/bb/build: enable access to logger within tasks
2016-12-12 21:53 [PATCH 0/1] lib/bb/build: enable access to logger within tasks Paul Eggleton
@ 2016-12-12 21:53 ` Paul Eggleton
0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggleton @ 2016-12-12 21:53 UTC (permalink / raw)
To: bitbake-devel
In certain circumstances it can be useful to get access to BitBake's
logger within a task; the main example is in OpenEmbedded's image
construction code where we want to be able to check the log file for
errors and warnings, but we don't want to see any errors or warnings
that were emitted through the logger; so we need a way to exclude those.
In order to do this, pass the logger object into the task via a
BB_TASK_LOGGER variable, and add a logging handler class to bb.utils
that can be added to it in order to keep a list of warnings/errors that
have been emitted.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
lib/bb/build.py | 1 +
lib/bb/utils.py | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 7a7aabb..0c2c1ba 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -562,6 +562,7 @@ def _exec_task(fn, task, d, quieterr):
localdata.setVar('BB_LOGFILE', logfn)
localdata.setVar('BB_RUNTASK', task)
+ localdata.setVar('BB_TASK_LOGGER', bblogger)
flags = localdata.getVarFlags(task)
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 9073f15..a22a05e 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1503,3 +1503,14 @@ def load_plugins(logger, plugins, pluginpath):
plugins.append(obj or plugin)
else:
plugins.append(plugin)
+
+
+class LogCatcher(logging.Handler):
+ """Logging handler for collecting logged messages so you can check them later"""
+ def __init__(self):
+ self.messages = []
+ logging.Handler.__init__(self, logging.WARNING)
+ def emit(self, record):
+ self.messages.append(bb.build.logformatter.format(record))
+ def contains(self, message):
+ return (message in self.messages)
--
2.5.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-12 21:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-12 21:53 [PATCH 0/1] lib/bb/build: enable access to logger within tasks Paul Eggleton
2016-12-12 21:53 ` [PATCH 1/1] " Paul Eggleton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.