* [PATCH 1/2] tinfoil: fix duplication of log messages
2017-06-07 19:04 [PATCH 0/2] Tinfoil log duplication fixes Paul Eggleton
@ 2017-06-07 19:04 ` Paul Eggleton
2017-06-07 19:04 ` [PATCH 2/2] knotty: prevent extra logger from being enabled for tinfoil Paul Eggleton
1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2017-06-07 19:04 UTC (permalink / raw)
To: bitbake-devel
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].
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
lib/bb/main.py | 4 ++--
lib/bb/tinfoil.py | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/bb/main.py b/lib/bb/main.py
index 8c948c2..29e3911 100755
--- a/lib/bb/main.py
+++ b/lib/bb/main.py
@@ -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)
diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 563c0c4..fb0da62 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -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
--
2.9.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] knotty: prevent extra logger from being enabled for tinfoil
2017-06-07 19:04 [PATCH 0/2] Tinfoil log duplication fixes Paul Eggleton
2017-06-07 19:04 ` [PATCH 1/2] tinfoil: fix duplication of log messages Paul Eggleton
@ 2017-06-07 19:04 ` Paul Eggleton
1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2017-06-07 19:04 UTC (permalink / raw)
To: bitbake-devel
tinfoil 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].
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
lib/bb/msg.py | 7 +++++++
lib/bb/ui/knotty.py | 5 +++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/bb/msg.py b/lib/bb/msg.py
index 90b1582..f1723be 100644
--- a/lib/bb/msg.py
+++ b/lib/bb/msg.py
@@ -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
diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 82aa7c4..a19c3b3 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -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")
--
2.9.4
^ permalink raw reply related [flat|nested] 3+ messages in thread