utils: ensure we show error messages on server startup

If a BBHandledException occurs that means some error was logged, so we
need to handle any pending events so that we can actually have the error
logged. Tinfoil should really be doing this for us but at this stage in
the release we can't really fix this there, so do it here for now.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.microsoft.com>
This commit is contained in:
Paul Eggleton 2021-10-20 10:02:56 +13:00
parent 38e6288c7d
commit e01254dd0d

View File

@ -205,7 +205,20 @@ def setup_tinfoil(bitbakepath, enable_tracking, loglevel=None):
tinfoil.logger.setLevel(logging.WARNING) tinfoil.logger.setLevel(logging.WARNING)
if loglevel: if loglevel:
tinfoil.logger.setLevel(loglevel) tinfoil.logger.setLevel(loglevel)
tinfoil.prepare(config_only = True) try:
tinfoil.prepare(config_only = True)
except bb.BBHandledException:
sys.exit(1)
finally:
# Handle any remaining events - needed if server failed and logged errors
# FIXME tinfoil.prepare() should really be doing this for us!
while True:
event = tinfoil.wait_event()
if not event:
break
if isinstance(event, logging.LogRecord):
if event.taskpid == 0 or event.levelno > logging.INFO:
tinfoil.logger.handle(event)
return tinfoil return tinfoil