summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-08-12 15:25:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-08-15 09:49:11 +0100
commita6c48298b17e6a5844b3638b422fe226e3b67b89 (patch)
treef8696377df2a3d8d06d6cc1ae418b6f4174dced7 /bitbake/lib/bb
parent09ce78cc4fcc6619fb4f527a88d5bca72a8c3e24 (diff)
downloadpoky-a6c48298b17e6a5844b3638b422fe226e3b67b89.tar.gz
bitbake/msg.py: Drop manually created domain lists
This patch removes the majority of the domain related code from bb.msg on the grounds that we now support dynamic creation of logging domains so having this hardcoded is just error prone and less flexible. It also makes the msg code overly and needlessly complex. It also removes the bb.msg.debug/note/warn/plain/error functions since we might as well remove them rather than try and fix them at this point. (Bitbake rev: 7627b561cbcb1482b464d69db70f38ea663180f3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/msg.py85
1 files changed, 4 insertions, 81 deletions
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index 77a7a0fed2..ecf756ee25 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -94,35 +94,6 @@ class BBLogFilter(object):
94 return False 94 return False
95 95
96 96
97class Loggers(dict):
98 def __getitem__(self, key):
99 if key in self:
100 return dict.__getitem__(self, key)
101 else:
102 log = logging.getLogger("BitBake.%s" % domain._fields[key])
103 dict.__setitem__(self, key, log)
104 return log
105
106def _NamedTuple(name, fields):
107 Tuple = collections.namedtuple(name, " ".join(fields))
108 return Tuple(*range(len(fields)))
109
110domain = _NamedTuple("Domain", (
111 "Default",
112 "Build",
113 "Cache",
114 "Collection",
115 "Data",
116 "Depends",
117 "Fetcher",
118 "Parsing",
119 "PersistData",
120 "Provider",
121 "RunQueue",
122 "TaskData",
123 "Util"))
124logger = logging.getLogger("BitBake")
125loggers = Loggers()
126 97
127# Message control functions 98# Message control functions
128# 99#
@@ -156,11 +127,6 @@ def addDefaultlogFilter(handler):
156 for (domainarg, iterator) in groupby(domains): 127 for (domainarg, iterator) in groupby(domains):
157 dlevel = len(tuple(iterator)) 128 dlevel = len(tuple(iterator))
158 debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1 129 debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1
159 for index, msgdomain in enumerate(domain._fields):
160 if msgdomain == domainarg:
161 break
162 else:
163 warn(None, "Logging domain %s is not valid, ignoring" % domainarg)
164 130
165 BBLogFilter(handler, level, debug_domains) 131 BBLogFilter(handler, level, debug_domains)
166 132
@@ -168,53 +134,10 @@ def addDefaultlogFilter(handler):
168# Message handling functions 134# Message handling functions
169# 135#
170 136
171def debug(level, msgdomain, msg):
172 warnings.warn("bb.msg.debug is deprecated in favor of the python 'logging' module",
173 DeprecationWarning, stacklevel=2)
174 level = logging.DEBUG - (level - 1)
175 if not msgdomain:
176 logger.debug(level, msg)
177 else:
178 loggers[msgdomain].debug(level, msg)
179
180def plain(msg):
181 warnings.warn("bb.msg.plain is deprecated in favor of the python 'logging' module",
182 DeprecationWarning, stacklevel=2)
183 logger.plain(msg)
184
185def note(level, msgdomain, msg):
186 warnings.warn("bb.msg.note is deprecated in favor of the python 'logging' module",
187 DeprecationWarning, stacklevel=2)
188 if level > 1:
189 if msgdomain:
190 logger.verbose(msg)
191 else:
192 loggers[msgdomain].verbose(msg)
193 else:
194 if msgdomain:
195 logger.info(msg)
196 else:
197 loggers[msgdomain].info(msg)
198
199def warn(msgdomain, msg):
200 warnings.warn("bb.msg.warn is deprecated in favor of the python 'logging' module",
201 DeprecationWarning, stacklevel=2)
202 if not msgdomain:
203 logger.warn(msg)
204 else:
205 loggers[msgdomain].warn(msg)
206
207def error(msgdomain, msg):
208 warnings.warn("bb.msg.error is deprecated in favor of the python 'logging' module",
209 DeprecationWarning, stacklevel=2)
210 if not msgdomain:
211 logger.error(msg)
212 else:
213 loggers[msgdomain].error(msg)
214
215def fatal(msgdomain, msg): 137def fatal(msgdomain, msg):
216 if not msgdomain: 138 if msgdomain:
217 logger.critical(msg) 139 logger = logging.getLogger("BitBake.%s" % msgdomin)
218 else: 140 else:
219 loggers[msgdomain].critical(msg) 141 logger = logging.getLogger("BitBake")
142 logger.critical(msg)
220 sys.exit(1) 143 sys.exit(1)