From f32a8bc7ff7a0b0750b6934a96f5d48391b1383a Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Mon, 9 Mar 2020 11:33:39 -0500 Subject: 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") Signed-off-by: Joshua Watt Signed-off-by: Richard Purdie --- lib/bb/__init__.py | 5 +++-- lib/bb/msg.py | 17 +++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py index 88641e280..acd4af13a 100644 --- a/lib/bb/__init__.py +++ b/lib/bb/__init__.py @@ -43,12 +43,13 @@ class BBLogger(Logger): Logger.__init__(self, name) def bbdebug(self, level, msg, *args, **kwargs): + loglevel = logging.DEBUG - level + 1 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 if level > (bb.msg.loggerDefaultDebugLevel): return - return self.log(logging.DEBUG - level + 1, msg, *args, **kwargs) + return self.log(loglevel, msg, *args, **kwargs) def plain(self, msg, *args, **kwargs): return self.log(logging.INFO + 1, msg, *args, **kwargs) diff --git a/lib/bb/msg.py b/lib/bb/msg.py index 33c0e2fa1..d1b0e929d 100644 --- a/lib/bb/msg.py +++ b/lib/bb/msg.py @@ -138,7 +138,7 @@ class BBLogFilterStdOut(BBLogFilter): loggerDefaultDebugLevel = 0 loggerDefaultVerbose = False loggerVerboseLogs = False -loggerDefaultDomains = [] +loggerDefaultDomains = {} def init_msgconfig(verbose, debug, debug_domains=None): """ @@ -148,15 +148,16 @@ def init_msgconfig(verbose, debug, debug_domains=None): bb.msg.loggerDefaultVerbose = verbose if verbose: bb.msg.loggerVerboseLogs = True + + bb.msg.loggerDefaultDomains = {} if debug_domains: - bb.msg.loggerDefaultDomains = debug_domains - else: - bb.msg.loggerDefaultDomains = [] + for (domainarg, iterator) in groupby(debug_domains): + dlevel = len(tuple(iterator)) + bb.msg.loggerDefaultDomains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1 def constructLogOptions(): debug = loggerDefaultDebugLevel verbose = loggerDefaultVerbose - domains = loggerDefaultDomains if debug: level = BBLogFormatter.DEBUG - debug + 1 @@ -165,11 +166,7 @@ def constructLogOptions(): else: level = BBLogFormatter.NOTE - debug_domains = {} - for (domainarg, iterator) in groupby(domains): - dlevel = len(tuple(iterator)) - debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1 - return level, debug_domains + return level, loggerDefaultDomains def addDefaultlogFilter(handler, cls = BBLogFilter, forcelevel=None): level, debug_domains = constructLogOptions() -- cgit 1.2.3-korg