1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 01:19:52 +00:00

bitbake: lib/bb/msg: Convert default domains to a dictionary

Converts the default domain variable to a dictionary where the keys are
the logging domains and the values are the logging level (instead of the
debug count). This makes it easier to deal with the logging domains and
the awkward conversion from a list to a dictionary only needs to be done
once when logging is initialized. Finally, other code has been written
that already assumes this variable is a dictionary, see:

f04cd93109 ("bitbake: lib/bb: Optimise out debug messages from cooker")

(Bitbake rev: f32a8bc7ff7a0b0750b6934a96f5d48391b1383a)

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-09 11:33:39 -05:00
committed by Richard Purdie
parent 954b5258f1
commit 26473bfbea
2 changed files with 10 additions and 12 deletions
+3 -2
View File
@@ -43,12 +43,13 @@ class BBLogger(Logger):
Logger.__init__(self, name) Logger.__init__(self, name)
def bbdebug(self, level, msg, *args, **kwargs): def bbdebug(self, level, msg, *args, **kwargs):
loglevel = logging.DEBUG - level + 1
if not bb.event.worker_pid: if not bb.event.worker_pid:
if self.name in bb.msg.loggerDefaultDomains and level > (bb.msg.loggerDefaultDomains[self.name]): if self.name in bb.msg.loggerDefaultDomains and loglevel > (bb.msg.loggerDefaultDomains[self.name]):
return return
if level > (bb.msg.loggerDefaultDebugLevel): if level > (bb.msg.loggerDefaultDebugLevel):
return return
return self.log(logging.DEBUG - level + 1, msg, *args, **kwargs) return self.log(loglevel, msg, *args, **kwargs)
def plain(self, msg, *args, **kwargs): def plain(self, msg, *args, **kwargs):
return self.log(logging.INFO + 1, msg, *args, **kwargs) return self.log(logging.INFO + 1, msg, *args, **kwargs)
+7 -10
View File
@@ -138,7 +138,7 @@ class BBLogFilterStdOut(BBLogFilter):
loggerDefaultDebugLevel = 0 loggerDefaultDebugLevel = 0
loggerDefaultVerbose = False loggerDefaultVerbose = False
loggerVerboseLogs = False loggerVerboseLogs = False
loggerDefaultDomains = [] loggerDefaultDomains = {}
def init_msgconfig(verbose, debug, debug_domains=None): def init_msgconfig(verbose, debug, debug_domains=None):
""" """
@@ -148,15 +148,16 @@ def init_msgconfig(verbose, debug, debug_domains=None):
bb.msg.loggerDefaultVerbose = verbose bb.msg.loggerDefaultVerbose = verbose
if verbose: if verbose:
bb.msg.loggerVerboseLogs = True bb.msg.loggerVerboseLogs = True
bb.msg.loggerDefaultDomains = {}
if debug_domains: if debug_domains:
bb.msg.loggerDefaultDomains = debug_domains for (domainarg, iterator) in groupby(debug_domains):
else: dlevel = len(tuple(iterator))
bb.msg.loggerDefaultDomains = [] bb.msg.loggerDefaultDomains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1
def constructLogOptions(): def constructLogOptions():
debug = loggerDefaultDebugLevel debug = loggerDefaultDebugLevel
verbose = loggerDefaultVerbose verbose = loggerDefaultVerbose
domains = loggerDefaultDomains
if debug: if debug:
level = BBLogFormatter.DEBUG - debug + 1 level = BBLogFormatter.DEBUG - debug + 1
@@ -165,11 +166,7 @@ def constructLogOptions():
else: else:
level = BBLogFormatter.NOTE level = BBLogFormatter.NOTE
debug_domains = {} return level, loggerDefaultDomains
for (domainarg, iterator) in groupby(domains):
dlevel = len(tuple(iterator))
debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1
return level, debug_domains
def addDefaultlogFilter(handler, cls = BBLogFilter, forcelevel=None): def addDefaultlogFilter(handler, cls = BBLogFilter, forcelevel=None):
level, debug_domains = constructLogOptions() level, debug_domains = constructLogOptions()