summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2020-03-09 11:33:39 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-13 11:29:23 +0000
commit26473bfbeaed905e72ca95cf69d7bef3422814ac (patch)
tree2023c98e0fa9378988ce5552052014faea1658ef /bitbake
parent954b5258f182c71f9df2862d2771b5bdc82099e2 (diff)
downloadpoky-26473bfbeaed905e72ca95cf69d7bef3422814ac.tar.gz
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>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/__init__.py5
-rw-r--r--bitbake/lib/bb/msg.py17
2 files changed, 10 insertions, 12 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py
index 88641e280b..acd4af13a8 100644
--- a/bitbake/lib/bb/__init__.py
+++ b/bitbake/lib/bb/__init__.py
@@ -43,12 +43,13 @@ class BBLogger(Logger):
43 Logger.__init__(self, name) 43 Logger.__init__(self, name)
44 44
45 def bbdebug(self, level, msg, *args, **kwargs): 45 def bbdebug(self, level, msg, *args, **kwargs):
46 loglevel = logging.DEBUG - level + 1
46 if not bb.event.worker_pid: 47 if not bb.event.worker_pid:
47 if self.name in bb.msg.loggerDefaultDomains and level > (bb.msg.loggerDefaultDomains[self.name]): 48 if self.name in bb.msg.loggerDefaultDomains and loglevel > (bb.msg.loggerDefaultDomains[self.name]):
48 return 49 return
49 if level > (bb.msg.loggerDefaultDebugLevel): 50 if level > (bb.msg.loggerDefaultDebugLevel):
50 return 51 return
51 return self.log(logging.DEBUG - level + 1, msg, *args, **kwargs) 52 return self.log(loglevel, msg, *args, **kwargs)
52 53
53 def plain(self, msg, *args, **kwargs): 54 def plain(self, msg, *args, **kwargs):
54 return self.log(logging.INFO + 1, msg, *args, **kwargs) 55 return self.log(logging.INFO + 1, msg, *args, **kwargs)
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index 33c0e2fa19..d1b0e929d4 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -138,7 +138,7 @@ class BBLogFilterStdOut(BBLogFilter):
138loggerDefaultDebugLevel = 0 138loggerDefaultDebugLevel = 0
139loggerDefaultVerbose = False 139loggerDefaultVerbose = False
140loggerVerboseLogs = False 140loggerVerboseLogs = False
141loggerDefaultDomains = [] 141loggerDefaultDomains = {}
142 142
143def init_msgconfig(verbose, debug, debug_domains=None): 143def init_msgconfig(verbose, debug, debug_domains=None):
144 """ 144 """
@@ -148,15 +148,16 @@ def init_msgconfig(verbose, debug, debug_domains=None):
148 bb.msg.loggerDefaultVerbose = verbose 148 bb.msg.loggerDefaultVerbose = verbose
149 if verbose: 149 if verbose:
150 bb.msg.loggerVerboseLogs = True 150 bb.msg.loggerVerboseLogs = True
151
152 bb.msg.loggerDefaultDomains = {}
151 if debug_domains: 153 if debug_domains:
152 bb.msg.loggerDefaultDomains = debug_domains 154 for (domainarg, iterator) in groupby(debug_domains):
153 else: 155 dlevel = len(tuple(iterator))
154 bb.msg.loggerDefaultDomains = [] 156 bb.msg.loggerDefaultDomains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1
155 157
156def constructLogOptions(): 158def constructLogOptions():
157 debug = loggerDefaultDebugLevel 159 debug = loggerDefaultDebugLevel
158 verbose = loggerDefaultVerbose 160 verbose = loggerDefaultVerbose
159 domains = loggerDefaultDomains
160 161
161 if debug: 162 if debug:
162 level = BBLogFormatter.DEBUG - debug + 1 163 level = BBLogFormatter.DEBUG - debug + 1
@@ -165,11 +166,7 @@ def constructLogOptions():
165 else: 166 else:
166 level = BBLogFormatter.NOTE 167 level = BBLogFormatter.NOTE
167 168
168 debug_domains = {} 169 return level, loggerDefaultDomains
169 for (domainarg, iterator) in groupby(domains):
170 dlevel = len(tuple(iterator))
171 debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1
172 return level, debug_domains
173 170
174def addDefaultlogFilter(handler, cls = BBLogFilter, forcelevel=None): 171def addDefaultlogFilter(handler, cls = BBLogFilter, forcelevel=None):
175 level, debug_domains = constructLogOptions() 172 level, debug_domains = constructLogOptions()