diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-28 15:27:28 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-30 08:43:36 +0100 |
commit | 25e52d34d06f800b38824fc21799dc43b31093f2 (patch) | |
tree | 3c3997707304d8f127edb6e0e0267e891c666b12 /bitbake/lib | |
parent | 3c1c4ceaa470957fe5633d65215f165a38d61be7 (diff) | |
download | poky-25e52d34d06f800b38824fc21799dc43b31093f2.tar.gz |
bitbake: 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.
(Bitbake rev: 45cff5734ba2ba8c8d36d17d722a5804d39b258b)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/event.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index 3827dcfba4..526c41f562 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -149,23 +149,30 @@ def print_ui_queue(): | |||
149 | 149 | ||
150 | # First check to see if we have any proper messages | 150 | # First check to see if we have any proper messages |
151 | msgprint = False | 151 | msgprint = False |
152 | msgerrs = False | ||
153 | |||
154 | # Should we print to stderr? | ||
155 | for event in ui_queue[:]: | ||
156 | if isinstance(event, logging.LogRecord) and event.levelno >= logging.WARNING: | ||
157 | msgerrs = True | ||
158 | break | ||
159 | |||
160 | if msgerrs: | ||
161 | logger.addHandler(stderr) | ||
162 | else: | ||
163 | logger.addHandler(stdout) | ||
164 | |||
152 | for event in ui_queue[:]: | 165 | for event in ui_queue[:]: |
153 | if isinstance(event, logging.LogRecord): | 166 | if isinstance(event, logging.LogRecord): |
154 | if event.levelno > logging.DEBUG: | 167 | if event.levelno > logging.DEBUG: |
155 | if event.levelno >= logging.WARNING: | ||
156 | logger.addHandler(stderr) | ||
157 | else: | ||
158 | logger.addHandler(stdout) | ||
159 | logger.handle(event) | 168 | logger.handle(event) |
160 | msgprint = True | 169 | msgprint = True |
161 | if msgprint: | ||
162 | return | ||
163 | 170 | ||
164 | # Nope, so just print all of the messages we have (including debug messages) | 171 | # Nope, so just print all of the messages we have (including debug messages) |
165 | logger.addHandler(stdout) | 172 | if not msgprint: |
166 | for event in ui_queue[:]: | 173 | for event in ui_queue[:]: |
167 | if isinstance(event, logging.LogRecord): | 174 | if isinstance(event, logging.LogRecord): |
168 | logger.handle(event) | 175 | logger.handle(event) |
169 | 176 | ||
170 | def fire_ui_handlers(event, d): | 177 | def fire_ui_handlers(event, d): |
171 | global _thread_lock | 178 | global _thread_lock |