bitbake: knotty: Treat verbconsole as a console output

The BitBake.verbconsole needs to be treated like a console output logger
(meaning that the TerminalFilter attaches an InteractConsoleLogFilter to
it), even if it's not directly attached to the root 'BitBake' logger.
First, assign a special "is_console" property to the relevant handlers,
then look for the property in the handlers from the configuration object
return by bb.msg.setLoggingConfig(). Finally, pass the list of all
handlers to the TerminalFilter object; it doesn't care about the
difference between console and errconsole, so pass all the relevant
handlers as a list.

This fixes cases where the console output was corrupted when messages
were sent to the 'BitBake.verbconsole' handler.

(Bitbake rev: 2010be588c74a99256df7b565a309c84c2973546)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt
2020-03-12 13:30:03 -05:00
committed by Richard Purdie
parent 0dd9e5a84d
commit 5ce50b3ce7

View File

@@ -149,7 +149,7 @@ class TerminalFilter(object):
cr = (25, 80) cr = (25, 80)
return cr return cr
def __init__(self, main, helper, console, errconsole, quiet): def __init__(self, main, helper, handlers, quiet):
self.main = main self.main = main
self.helper = helper self.helper = helper
self.cuu = None self.cuu = None
@@ -179,14 +179,9 @@ class TerminalFilter(object):
termios.tcsetattr(fd, termios.TCSADRAIN, new) termios.tcsetattr(fd, termios.TCSADRAIN, new)
curses.setupterm() curses.setupterm()
if curses.tigetnum("colors") > 2: if curses.tigetnum("colors") > 2:
if console: for h in handlers:
try: try:
console.formatter.enable_color() h.formatter.enable_color()
except AttributeError:
pass
if errconsole:
try:
errconsole.formatter.enable_color()
except AttributeError: except AttributeError:
pass pass
self.ed = curses.tigetstr("ed") self.ed = curses.tigetstr("ed")
@@ -204,10 +199,9 @@ class TerminalFilter(object):
self.interactive = False self.interactive = False
bb.note("Unable to use interactive mode for this terminal, using fallback") bb.note("Unable to use interactive mode for this terminal, using fallback")
return return
if console:
console.addFilter(InteractConsoleLogFilter(self)) for h in handlers:
if errconsole: h.addFilter(InteractConsoleLogFilter(self))
errconsole.addFilter(InteractConsoleLogFilter(self))
self.main_progress = None self.main_progress = None
@@ -411,6 +405,9 @@ def main(server, eventHandler, params, tf = TerminalFilter):
"level": console_loglevel, "level": console_loglevel,
"stream": "ext://sys.stdout", "stream": "ext://sys.stdout",
"filters": ["BitBake.stdoutFilter"], "filters": ["BitBake.stdoutFilter"],
".": {
"is_console": True,
},
}, },
"BitBake.errconsole": { "BitBake.errconsole": {
"class": "logging.StreamHandler", "class": "logging.StreamHandler",
@@ -418,6 +415,9 @@ def main(server, eventHandler, params, tf = TerminalFilter):
"level": loglevel, "level": loglevel,
"stream": "ext://sys.stderr", "stream": "ext://sys.stderr",
"filters": ["BitBake.stderrFilter"], "filters": ["BitBake.stderrFilter"],
".": {
"is_console": True,
},
}, },
# This handler can be used if specific loggers should print on # This handler can be used if specific loggers should print on
# the console at a lower severity than the default. It will # the console at a lower severity than the default. It will
@@ -430,6 +430,9 @@ def main(server, eventHandler, params, tf = TerminalFilter):
"level": 1, "level": 1,
"stream": "ext://sys.stdout", "stream": "ext://sys.stdout",
"filters": ["BitBake.verbconsoleFilter"], "filters": ["BitBake.verbconsoleFilter"],
".": {
"is_console": True,
},
}, },
}, },
"formatters": { "formatters": {
@@ -523,7 +526,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
except OSError: except OSError:
pass pass
bb.msg.setLoggingConfig(logconfig, logconfigfile) conf = bb.msg.setLoggingConfig(logconfig, logconfigfile)
if sys.stdin.isatty() and sys.stdout.isatty(): if sys.stdin.isatty() and sys.stdout.isatty():
log_exec_tty = True log_exec_tty = True
@@ -534,14 +537,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
# Look for the specially designated handlers which need to be passed to the # Look for the specially designated handlers which need to be passed to the
# terminal handler # terminal handler
console = None console_handlers = [h for h in conf.config['handlers'].values() if getattr(h, 'is_console', False)]
errconsole = None
for h in logger.handlers:
name = getattr(h, '_name', None)
if name == 'BitBake.console':
console = h
elif name == 'BitBake.errconsole':
errconsole = h
bb.utils.set_process_name("KnottyUI") bb.utils.set_process_name("KnottyUI")
@@ -591,7 +587,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
printinterval = 5000 printinterval = 5000
lastprint = time.time() lastprint = time.time()
termfilter = tf(main, helper, console, errconsole, params.options.quiet) termfilter = tf(main, helper, console_handlers, params.options.quiet)
atexit.register(termfilter.finish) atexit.register(termfilter.finish)
while True: while True: