diff options
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r-- | bitbake/lib/bb/event.py | 51 |
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 | ||
25 | import os, sys | 25 | import os, sys |
26 | import warnings | 26 | import warnings |
27 | import bb.utils | ||
28 | import pickle | 27 | import pickle |
28 | import logging | ||
29 | import 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 | ||
57 | def fire_class_handlers(event, d): | 58 | def 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 | |||
303 | class MsgBase(Event): | ||
304 | """Base class for messages""" | ||
305 | |||
306 | def __init__(self, msg): | ||
307 | self._message = msg | ||
308 | Event.__init__(self) | ||
309 | |||
310 | class MsgDebug(MsgBase): | ||
311 | """Debug Message""" | ||
312 | |||
313 | class MsgNote(MsgBase): | ||
314 | """Note Message""" | ||
315 | |||
316 | class MsgWarn(MsgBase): | ||
317 | """Warning Message""" | ||
318 | |||
319 | class MsgError(MsgBase): | ||
320 | """Error Message""" | ||
321 | |||
322 | class MsgFatal(MsgBase): | ||
323 | """Fatal Message""" | ||
324 | |||
325 | class MsgPlain(MsgBase): | ||
326 | """General output""" | ||
327 | |||
328 | class 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 | |||