summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-28 15:27:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-28 15:54:02 +0100
commit45cff5734ba2ba8c8d36d17d722a5804d39b258b (patch)
tree4a99e9ef62218515143f76eb899b222a4db0cf5c
parentfdcea991baa4f83d9c98d468d7b49c8c388a4a15 (diff)
downloadbitbake-contrib-45cff5734ba2ba8c8d36d17d722a5804d39b258b.tar.gz
bitbake-contrib-45cff5734ba2ba8c8d36d17d722a5804d39b258b.tar.bz2
bitbake-contrib-45cff5734ba2ba8c8d36d17d722a5804d39b258b.zip
event: Don't write duplicate logs to stdout and stderr in no UI case
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>
-rw-r--r--lib/bb/event.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/bb/event.py b/lib/bb/event.py
index 3827dcfba4..526c41f562 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