[gnome-continuous-yocto/gnomeostree-3.28-rocko: 6202/8267] bitbake: knotty: prevent extra logger from being enabled for tinfoil



commit 55c4781cdef853480d9e9d94f5aee26c512777c3
Author: Paul Eggleton <paul eggleton linux intel com>
Date:   Wed Jun 7 21:04:17 2017 +0200

    bitbake: knotty: prevent extra logger from being enabled for tinfoil
    
    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].
    
    (Bitbake rev: 66d866745f35468d1540a793d07e3a401298b84b)
    
    Signed-off-by: Paul Eggleton <paul eggleton linux intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 bitbake/lib/bb/msg.py       |    7 +++++++
 bitbake/lib/bb/ui/knotty.py |    5 +++--
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index 90b1582..f1723be 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/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/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 82aa7c4..a19c3b3 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/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")
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]