All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] event: Don't write duplicate logs to stdout and stderr in no UI case
@ 2017-07-28 14:55 Richard Purdie
  2017-07-28 14:55 ` [PATCH 2/7] process: Ensure ConnectionReader/Writer have fileno() and close() methods Richard Purdie
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Richard Purdie @ 2017-07-28 14:55 UTC (permalink / raw)
  To: bitbake-devel

This code would duplicate messages to stdout and stderr when no UI connected
and there were error level messages.

Rework the code so it either uses stderr (for errors and above) or
stdout for warnings/debug but not both for the same messages.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/event.py | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/lib/bb/event.py b/lib/bb/event.py
index 3827dcf..526c41f 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -149,23 +149,30 @@ def print_ui_queue():
 
         # First check to see if we have any proper messages
         msgprint = False
+        msgerrs = False
+
+        # Should we print to stderr?
+        for event in ui_queue[:]:
+            if isinstance(event, logging.LogRecord) and event.levelno >= logging.WARNING:
+                msgerrs = True
+                break
+
+        if msgerrs:
+            logger.addHandler(stderr)
+        else:
+            logger.addHandler(stdout)
+
         for event in ui_queue[:]:
             if isinstance(event, logging.LogRecord):
                 if event.levelno > logging.DEBUG:
-                    if event.levelno >= logging.WARNING:
-                        logger.addHandler(stderr)
-                    else:
-                        logger.addHandler(stdout)
                     logger.handle(event)
                     msgprint = True
-        if msgprint:
-            return
 
         # Nope, so just print all of the messages we have (including debug messages)
-        logger.addHandler(stdout)
-        for event in ui_queue[:]:
-            if isinstance(event, logging.LogRecord):
-                logger.handle(event)
+        if not msgprint:
+            for event in ui_queue[:]:
+                if isinstance(event, logging.LogRecord):
+                    logger.handle(event)
 
 def fire_ui_handlers(event, d):
     global _thread_lock
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-07-28 14:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 14:55 [PATCH 1/7] event: Don't write duplicate logs to stdout and stderr in no UI case Richard Purdie
2017-07-28 14:55 ` [PATCH 2/7] process: Ensure ConnectionReader/Writer have fileno() and close() methods Richard Purdie
2017-07-28 14:55 ` [PATCH 3/7] process: Allow BBUIEventQueue to exit cleanly Richard Purdie
2017-07-28 14:55 ` [PATCH 4/7] process: Move socket keep alive into BitBakeProcessServerConnection Richard Purdie
2017-07-28 14:55 ` [PATCH 5/7] process/cooker: Allow UI process to know if the cooker was started successfully Richard Purdie
2017-07-28 14:55 ` [PATCH 6/7] process: Don't leak open pipes upon reconnection Richard Purdie
2017-07-28 14:55 ` [PATCH 7/7] process: Clean up server communication timeout errors Richard Purdie

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.