mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
3e57e63b2d
commit
4855548ffb
+49
-2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user