summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/event.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-06-09 16:17:29 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:33 +0000
commit4855548ffbbb6b972f6b71d61d2b29e4758acdc7 (patch)
tree259485fe325ac4770002b4d8c53288be71bc8fc8 /bitbake/lib/bb/event.py
parent3e57e63b2d16fa3f1ec37a904e8538e00a301fdd (diff)
downloadpoky-4855548ffbbb6b972f6b71d61d2b29e4758acdc7.tar.gz
Use the python logging module under the hood for bb.msg
(Bitbake rev: 47ca82397bc395b598c6b68b24cdee9e0d8a76d8) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
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