summaryrefslogtreecommitdiff
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)
downloadopenembedded-core-4855548ffbbb6b972f6b71d61d2b29e4758acdc7.tar.gz
openembedded-core-4855548ffbbb6b972f6b71d61d2b29e4758acdc7.tar.bz2
openembedded-core-4855548ffbbb6b972f6b71d61d2b29e4758acdc7.zip
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.
import os, sys
import warnings
-import bb.utils
import pickle
+import logging
+import bb.utils
# This is the pid for which we should generate the event. This is set when
# the runqueue forks off.
@@ -56,7 +57,7 @@ bb.utils._context["Handled"] = Handled
def fire_class_handlers(event, d):
import bb.msg
- if isinstance(event, bb.msg.MsgBase):
+ if isinstance(event, MsgBase):
return
for handler in _handlers:
@@ -298,3 +299,49 @@ class DepTreeGenerated(Event):
def __init__(self, depgraph):
Event.__init__(self)
self._depgraph = depgraph
+
+class MsgBase(Event):
+ """Base class for messages"""
+
+ def __init__(self, msg):
+ self._message = msg
+ Event.__init__(self)
+
+class MsgDebug(MsgBase):
+ """Debug Message"""
+
+class MsgNote(MsgBase):
+ """Note Message"""
+
+class MsgWarn(MsgBase):
+ """Warning Message"""
+
+class MsgError(MsgBase):
+ """Error Message"""
+
+class MsgFatal(MsgBase):
+ """Fatal Message"""
+
+class MsgPlain(MsgBase):
+ """General output"""
+
+class LogHandler(logging.Handler):
+ """Dispatch logging messages as bitbake events"""
+
+ messages = (
+ (logging.DEBUG, MsgDebug),
+ (logging.INFO, MsgNote),
+ (logging.WARNING, MsgWarn),
+ (logging.ERROR, MsgError),
+ (logging.CRITICAL, MsgFatal),
+ )
+
+ def emit(self, record):
+ for level, msgclass in self.messages:
+ if record.levelno <= level:
+ msg = self.format(record)
+ fire(msgclass(msg), None)
+ if bb.event.useStdout:
+ print(record.levelname + ": " + record.getMessage())
+ break
+