mirror of
https://git.yoctoproject.org/poky
synced 2026-06-03 01:40:07 +00:00
Switch bitbake internals to use logging directly rather than bb.msg
We use a custom Logger subclass for our loggers This logger provides: - 'debug' method which accepts a debug level - 'plain' method which bypasses log formatting - 'verbose' method which is more detail than info, but less than debug (Bitbake rev: 3b2c1fe5ca56daebb24073a9dd45723d3efd2a8d) 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
d3a45c7d41
commit
ecc68fa4fb
@@ -35,7 +35,25 @@ class NullHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
pass
|
||||
|
||||
Logger = logging.getLoggerClass()
|
||||
class BBLogger(Logger):
|
||||
def __init__(self, name):
|
||||
if name.split(".")[0] == "BitBake":
|
||||
self.debug = self.bbdebug
|
||||
Logger.__init__(self, name)
|
||||
|
||||
def bbdebug(self, level, msg, *args, **kwargs):
|
||||
return self.log(logging.DEBUG - level - 1, msg, *args, **kwargs)
|
||||
|
||||
def plain(self, msg, *args, **kwargs):
|
||||
return self.log(logging.INFO + 1, msg, *args, **kwargs)
|
||||
|
||||
def verbose(self, msg, *args, **kwargs):
|
||||
return self.log(logging.INFO - 1, msg, *args, **kwargs)
|
||||
|
||||
logging.raiseExceptions = False
|
||||
logging.setLoggerClass(BBLogger)
|
||||
|
||||
logger = logging.getLogger("BitBake")
|
||||
logger.addHandler(NullHandler())
|
||||
logger.setLevel(logging.INFO)
|
||||
@@ -48,22 +66,23 @@ if "BBDEBUG" in os.environ:
|
||||
|
||||
# Messaging convenience functions
|
||||
def plain(*args):
|
||||
bb.msg.plain(''.join(args))
|
||||
logger.plain(''.join(args))
|
||||
|
||||
def debug(lvl, *args):
|
||||
bb.msg.debug(lvl, None, ''.join(args))
|
||||
logger.debug(lvl, ''.join(args))
|
||||
|
||||
def note(*args):
|
||||
bb.msg.note(1, None, ''.join(args))
|
||||
logger.info(''.join(args))
|
||||
|
||||
def warn(*args):
|
||||
bb.msg.warn(None, ''.join(args))
|
||||
logger.warn(''.join(args))
|
||||
|
||||
def error(*args):
|
||||
bb.msg.error(None, ''.join(args))
|
||||
logger.error(''.join(args))
|
||||
|
||||
def fatal(*args):
|
||||
bb.msg.fatal(None, ''.join(args))
|
||||
logger.critical(''.join(args))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def deprecated(func, name = None, advice = ""):
|
||||
|
||||
Reference in New Issue
Block a user