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.py51
1 files changed, 49 insertions, 2 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 45458c2d63..c04ffd5ac1 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -24,8 +24,9 @@ BitBake build tools.
24 24
25import os, sys 25import os, sys
26import warnings 26import warnings
27import bb.utils
28import pickle 27import pickle
28import logging
29import bb.utils
29 30
30# This is the pid for which we should generate the event. This is set when 31# This is the pid for which we should generate the event. This is set when
31# the runqueue forks off. 32# the runqueue forks off.
@@ -56,7 +57,7 @@ bb.utils._context["Handled"] = Handled
56 57
57def fire_class_handlers(event, d): 58def fire_class_handlers(event, d):
58 import bb.msg 59 import bb.msg
59 if isinstance(event, bb.msg.MsgBase): 60 if isinstance(event, MsgBase):
60 return 61 return
61 62
62 for handler in _handlers: 63 for handler in _handlers:
@@ -298,3 +299,49 @@ class DepTreeGenerated(Event):
298 def __init__(self, depgraph): 299 def __init__(self, depgraph):
299 Event.__init__(self) 300 Event.__init__(self)
300 self._depgraph = depgraph 301 self._depgraph = depgraph
302
303class MsgBase(Event):
304 """Base class for messages"""
305
306 def __init__(self, msg):
307 self._message = msg
308 Event.__init__(self)
309
310class MsgDebug(MsgBase):
311 """Debug Message"""
312
313class MsgNote(MsgBase):
314 """Note Message"""
315
316class MsgWarn(MsgBase):
317 """Warning Message"""
318
319class MsgError(MsgBase):
320 """Error Message"""
321
322class MsgFatal(MsgBase):
323 """Fatal Message"""
324
325class MsgPlain(MsgBase):
326 """General output"""
327
328class LogHandler(logging.Handler):
329 """Dispatch logging messages as bitbake events"""
330
331 messages = (
332 (logging.DEBUG, MsgDebug),
333 (logging.INFO, MsgNote),
334 (logging.WARNING, MsgWarn),
335 (logging.ERROR, MsgError),
336 (logging.CRITICAL, MsgFatal),
337 )
338
339 def emit(self, record):
340 for level, msgclass in self.messages:
341 if record.levelno <= level:
342 msg = self.format(record)
343 fire(msgclass(msg), None)
344 if bb.event.useStdout:
345 print(record.levelname + ": " + record.getMessage())
346 break
347