aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/event.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bb/event.py')
-rw-r--r--lib/bb/event.py48
1 files changed, 46 insertions, 2 deletions
diff --git a/lib/bb/event.py b/lib/bb/event.py
index 7731649ef..dbcd11e1b 100644
--- a/lib/bb/event.py
+++ b/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.
@@ -55,7 +56,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,46 @@ 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)
+ break