summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/event.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r--bitbake/lib/bb/event.py25
1 files changed, 25 insertions, 0 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):
207def register_UIHhandler(handler): 210def 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
212def unregister_UIHhandler(handlerNum): 217def 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
223class 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
217def getName(e): 242def 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: