diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/event.py | 25 | ||||
-rw-r--r-- | bitbake/lib/bb/msg.py | 7 |
2 files changed, 30 insertions, 2 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index ba25d38d89..8ffd2c3e18 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -63,6 +63,7 @@ def clean_class_handlers(): | |||
63 | # Internal | 63 | # Internal |
64 | _handlers = clean_class_handlers() | 64 | _handlers = clean_class_handlers() |
65 | _ui_handlers = {} | 65 | _ui_handlers = {} |
66 | _ui_logfilters = {} | ||
66 | _ui_handler_seq = 0 | 67 | _ui_handler_seq = 0 |
67 | _event_handler_map = {} | 68 | _event_handler_map = {} |
68 | _catchall_handlers = {} | 69 | _catchall_handlers = {} |
@@ -135,6 +136,8 @@ def fire_ui_handlers(event, d): | |||
135 | for h in _ui_handlers: | 136 | for h in _ui_handlers: |
136 | #print "Sending event %s" % event | 137 | #print "Sending event %s" % event |
137 | try: | 138 | try: |
139 | if not _ui_logfilters[h].filter(event): | ||
140 | continue | ||
138 | # We use pickle here since it better handles object instances | 141 | # We use pickle here since it better handles object instances |
139 | # which xmlrpc's marshaller does not. Events *must* be serializable | 142 | # which xmlrpc's marshaller does not. Events *must* be serializable |
140 | # by pickle. | 143 | # by pickle. |
@@ -207,6 +210,8 @@ def remove(name, handler): | |||
207 | def register_UIHhandler(handler): | 210 | def register_UIHhandler(handler): |
208 | bb.event._ui_handler_seq = bb.event._ui_handler_seq + 1 | 211 | bb.event._ui_handler_seq = bb.event._ui_handler_seq + 1 |
209 | _ui_handlers[_ui_handler_seq] = handler | 212 | _ui_handlers[_ui_handler_seq] = handler |
213 | level, debug_domains = bb.msg.constructLogOptions() | ||
214 | _ui_logfilters[_ui_handler_seq] = UIEventFilter(level, debug_domains) | ||
210 | return _ui_handler_seq | 215 | return _ui_handler_seq |
211 | 216 | ||
212 | def unregister_UIHhandler(handlerNum): | 217 | def unregister_UIHhandler(handlerNum): |
@@ -214,6 +219,26 @@ def unregister_UIHhandler(handlerNum): | |||
214 | del _ui_handlers[handlerNum] | 219 | del _ui_handlers[handlerNum] |
215 | return | 220 | return |
216 | 221 | ||
222 | # Class to allow filtering of events and specific filtering of LogRecords *before* we put them over the IPC | ||
223 | class UIEventFilter(object): | ||
224 | def __init__(self, level, debug_domains): | ||
225 | self.update(None, level, debug_domains) | ||
226 | |||
227 | def update(self, eventmask, level, debug_domains): | ||
228 | self.eventmask = None | ||
229 | self.stdlevel = level | ||
230 | self.debug_domains = debug_domains | ||
231 | |||
232 | def filter(self, event): | ||
233 | if isinstance(event, logging.LogRecord): | ||
234 | if event.levelno >= self.stdlevel: | ||
235 | return True | ||
236 | if event.name in self.debug_domains and event.levelno >= self.debug_domains[event.name]: | ||
237 | return True | ||
238 | return False | ||
239 | # Implement other event masking here on self.eventmask | ||
240 | return True | ||
241 | |||
217 | def getName(e): | 242 | def getName(e): |
218 | """Returns the name of a class or class instance""" | 243 | """Returns the name of a class or class instance""" |
219 | if getattr(e, "__name__", None) == None: | 244 | if getattr(e, "__name__", None) == None: |
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py index e70daee92f..59769707e0 100644 --- a/bitbake/lib/bb/msg.py +++ b/bitbake/lib/bb/msg.py | |||
@@ -146,8 +146,7 @@ def init_msgconfig(verbose, debug, debug_domains = []): | |||
146 | bb.msg.loggerVerboseLogs = True | 146 | bb.msg.loggerVerboseLogs = True |
147 | bb.msg.loggerDefaultDomains = debug_domains | 147 | bb.msg.loggerDefaultDomains = debug_domains |
148 | 148 | ||
149 | def addDefaultlogFilter(handler): | 149 | def constructLogOptions(): |
150 | |||
151 | debug = loggerDefaultDebugLevel | 150 | debug = loggerDefaultDebugLevel |
152 | verbose = loggerDefaultVerbose | 151 | verbose = loggerDefaultVerbose |
153 | domains = loggerDefaultDomains | 152 | domains = loggerDefaultDomains |
@@ -163,6 +162,10 @@ def addDefaultlogFilter(handler): | |||
163 | for (domainarg, iterator) in groupby(domains): | 162 | for (domainarg, iterator) in groupby(domains): |
164 | dlevel = len(tuple(iterator)) | 163 | dlevel = len(tuple(iterator)) |
165 | debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1 | 164 | debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1 |
165 | return level, debug_domains | ||
166 | |||
167 | def addDefaultlogFilter(handler): | ||
168 | level, debug_domains = constructLogOptions() | ||
166 | 169 | ||
167 | BBLogFilter(handler, level, debug_domains) | 170 | BBLogFilter(handler, level, debug_domains) |
168 | 171 | ||