summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2020-03-09 11:33:47 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-13 11:29:23 +0000
commit300fd2a659a50e84b4fff0c76398cbbd1d62f5d1 (patch)
treec0c53de395f8813be2d29d3d16059f1bcd68ddfc /bitbake/lib/bb
parent6b9eacb404914c24126c4ee08db68b2503f376f0 (diff)
downloadpoky-300fd2a659a50e84b4fff0c76398cbbd1d62f5d1.tar.gz
bitbake: knotty: Remove dependency on format variable
Passing around the log formatter variable was unnecessary since the log levels of interest can be accesses as class members of bb.msg.BBLogFormatter. Switching to do this will make using the structured python logging much easier, since it can be difficult to extract out the formatter for a specific handler. (Bitbake rev: c1c867df24b4ef204027d485acac7c75c63f2bc0) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/tinfoil.py4
-rw-r--r--bitbake/lib/bb/ui/knotty.py32
2 files changed, 21 insertions, 15 deletions
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index 9560eb5b49..5c5be456e2 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -735,11 +735,9 @@ class Tinfoil:
735 console = handler 735 console = handler
736 elif handler.stream == sys.stderr: 736 elif handler.stream == sys.stderr:
737 errconsole = handler 737 errconsole = handler
738 format_str = "%(levelname)s: %(message)s"
739 format = bb.msg.BBLogFormatter(format_str)
740 helper.shutdown = 0 738 helper.shutdown = 0
741 parseprogress = None 739 parseprogress = None
742 termfilter = bb.ui.knotty.TerminalFilter(helper, helper, console, errconsole, format, quiet=self.quiet) 740 termfilter = bb.ui.knotty.TerminalFilter(helper, helper, console, errconsole, quiet=self.quiet)
743 try: 741 try:
744 while True: 742 while True:
745 try: 743 try:
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index aac12cd479..d5dce7172a 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -109,12 +109,11 @@ def pluralise(singular, plural, qty):
109 109
110 110
111class InteractConsoleLogFilter(logging.Filter): 111class InteractConsoleLogFilter(logging.Filter):
112 def __init__(self, tf, format): 112 def __init__(self, tf):
113 self.tf = tf 113 self.tf = tf
114 self.format = format
115 114
116 def filter(self, record): 115 def filter(self, record):
117 if record.levelno == self.format.NOTE and (record.msg.startswith("Running") or record.msg.startswith("recipe ")): 116 if record.levelno == bb.msg.BBLogFormatter.NOTE and (record.msg.startswith("Running") or record.msg.startswith("recipe ")):
118 return False 117 return False
119 self.tf.clearFooter() 118 self.tf.clearFooter()
120 return True 119 return True
@@ -150,7 +149,7 @@ class TerminalFilter(object):
150 cr = (25, 80) 149 cr = (25, 80)
151 return cr 150 return cr
152 151
153 def __init__(self, main, helper, console, errconsole, format, quiet): 152 def __init__(self, main, helper, console, errconsole, quiet):
154 self.main = main 153 self.main = main
155 self.helper = helper 154 self.helper = helper
156 self.cuu = None 155 self.cuu = None
@@ -180,7 +179,16 @@ class TerminalFilter(object):
180 termios.tcsetattr(fd, termios.TCSADRAIN, new) 179 termios.tcsetattr(fd, termios.TCSADRAIN, new)
181 curses.setupterm() 180 curses.setupterm()
182 if curses.tigetnum("colors") > 2: 181 if curses.tigetnum("colors") > 2:
183 format.enable_color() 182 if console:
183 try:
184 console.formatter.enable_color()
185 except AttributeError:
186 pass
187 if errconsole:
188 try:
189 errconsole.formatter.enable_color()
190 except AttributeError:
191 pass
184 self.ed = curses.tigetstr("ed") 192 self.ed = curses.tigetstr("ed")
185 if self.ed: 193 if self.ed:
186 self.cuu = curses.tigetstr("cuu") 194 self.cuu = curses.tigetstr("cuu")
@@ -197,9 +205,9 @@ class TerminalFilter(object):
197 bb.note("Unable to use interactive mode for this terminal, using fallback") 205 bb.note("Unable to use interactive mode for this terminal, using fallback")
198 return 206 return
199 if console: 207 if console:
200 console.addFilter(InteractConsoleLogFilter(self, format)) 208 console.addFilter(InteractConsoleLogFilter(self))
201 if errconsole: 209 if errconsole:
202 errconsole.addFilter(InteractConsoleLogFilter(self, format)) 210 errconsole.addFilter(InteractConsoleLogFilter(self))
203 211
204 self.main_progress = None 212 self.main_progress = None
205 213
@@ -469,7 +477,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
469 printinterval = 5000 477 printinterval = 5000
470 lastprint = time.time() 478 lastprint = time.time()
471 479
472 termfilter = tf(main, helper, console, errconsole, format, params.options.quiet) 480 termfilter = tf(main, helper, console, errconsole, params.options.quiet)
473 atexit.register(termfilter.finish) 481 atexit.register(termfilter.finish)
474 482
475 while True: 483 while True:
@@ -508,21 +516,21 @@ def main(server, eventHandler, params, tf = TerminalFilter):
508 if isinstance(event, logging.LogRecord): 516 if isinstance(event, logging.LogRecord):
509 lastprint = time.time() 517 lastprint = time.time()
510 printinterval = 5000 518 printinterval = 5000
511 if event.levelno >= format.ERROR: 519 if event.levelno >= bb.msg.BBLogFormatter.ERROR:
512 errors = errors + 1 520 errors = errors + 1
513 return_value = 1 521 return_value = 1
514 elif event.levelno == format.WARNING: 522 elif event.levelno == bb.msg.BBLogFormatter.WARNING:
515 warnings = warnings + 1 523 warnings = warnings + 1
516 524
517 if event.taskpid != 0: 525 if event.taskpid != 0:
518 # For "normal" logging conditions, don't show note logs from tasks 526 # For "normal" logging conditions, don't show note logs from tasks
519 # but do show them if the user has changed the default log level to 527 # but do show them if the user has changed the default log level to
520 # include verbose/debug messages 528 # include verbose/debug messages
521 if event.levelno <= format.NOTE and (event.levelno < llevel or (event.levelno == format.NOTE and llevel != format.VERBOSE)): 529 if event.levelno <= bb.msg.BBLogFormatter.NOTE and (event.levelno < llevel or (event.levelno == bb.msg.BBLogFormatter.NOTE and llevel != bb.msg.BBLogFormatter.VERBOSE)):
522 continue 530 continue
523 531
524 # Prefix task messages with recipe/task 532 # Prefix task messages with recipe/task
525 if event.taskpid in helper.pidmap and event.levelno != format.PLAIN: 533 if event.taskpid in helper.pidmap and event.levelno != bb.msg.BBLogFormatter.PLAIN:
526 taskinfo = helper.running_tasks[helper.pidmap[event.taskpid]] 534 taskinfo = helper.running_tasks[helper.pidmap[event.taskpid]]
527 event.msg = taskinfo['title'] + ': ' + event.msg 535 event.msg = taskinfo['title'] + ': ' + event.msg
528 if hasattr(event, 'fn'): 536 if hasattr(event, 'fn'):