Tinfoil log duplication fixes
cover Tinfoil log duplication fixes
The following changes since commit 705ab252e631903e6d2e46202b419a9e8adcd861:
bitbake-layers: check layer dependencies before adding (2017-06-05 13:33:14 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib paule/bb-tinfoil-logging
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/bb-tinfoil-logging
Paul Eggleton (2):
tinfoil: fix duplication of log messages
knotty: prevent extra logger from being enabled for tinfoil
lib/bb/main.py | 4 ++-- lib/bb/msg.py | 7 +++++++ lib/bb/tinfoil.py | 3 ++- lib/bb/ui/knotty.py | 5 +++-- 4 files changed, 14 insertions(+), 5 deletions(-)
Signature · 1 line
2.9.4
PATCH 1/2 tinfoil: fix duplication of log messages
Adding an additional logger in setup_bitbake() interacts poorly with the logger we have added by default in tinfoil's constructor, with the result that messages may be doubled or even tripled in tinfoil-using scripts. Disable adding this one when calling setup_bitbake() from tinfoil to avoid this problem.
Part of the fix for [YOCTO #11275].
--- lib/bb/main.py | 4 ++-- lib/bb/tinfoil.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)
lib/bb/main.py +2 -2
@@ -477,10 +477,10 @@ def bitbake_main(configParams, configuration): return 1 -def setup_bitbake(configParams, configuration, extrafeatures=None): +def setup_bitbake(configParams, configuration, extrafeatures=None, setup_logging=True): # Ensure logging messages get sent to the UI as events handler = bb.event.LogHandler() - if not configParams.status_only: + if setup_logging and not configParams.status_only: # In status only mode there are no logs and no UI logger.addHandler(handler)
lib/bb/tinfoil.py +2 -1
@@ -245,7 +245,8 @@ class Tinfoil: server, self.server_connection, ui_module = setup_bitbake(config_params, cookerconfig, - extrafeatures) + extrafeatures, + setup_logging=False) self.ui_module = ui_module
Signature · 1 line
2.9.4
PATCH 2/2 knotty: prevent extra logger from being enabled for tinfoil
In reply to Paul Eggletontinfoil sets up its own logger by default, but if and when we initialise the UI (by default knotty) will also set one up, leading to duplicated messages specifically from tasks. To avoid this, rather than adding some kind of parameter, just check if there is already a logger outputting to stdout/stderr and if so, skip adding our own.
Part of the fix for [YOCTO #11275].
--- lib/bb/msg.py | 7 +++++++ lib/bb/ui/knotty.py | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-)
lib/bb/msg.py +7 -0
@@ -216,3 +216,10 @@ def logger_create(name, output=sys.stderr, level=logging.INFO, preserve_handlers logger.handlers = [console] logger.setLevel(level) return logger + +def has_console_handler(logger): + for handler in logger.handlers: + if isinstance(handler, logging.StreamHandler): + if handler.stream in [sys.stderr, sys.stdout]: + return True + return False
lib/bb/ui/knotty.py +3 -2
@@ -365,8 +365,9 @@ def main(server, eventHandler, params, tf = TerminalFilter): bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr) console.setFormatter(format) errconsole.setFormatter(format) - logger.addHandler(console) - logger.addHandler(errconsole) + if not bb.msg.has_console_handler(logger): + logger.addHandler(console) + logger.addHandler(errconsole) bb.utils.set_process_name("KnottyUI")
Signature · 1 line
2.9.4