mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
bitbake: bitbake: lib: Add PrefixLoggerAdapter helper
Adds a helper logger adapter to add a prefix to all log messages. This is useful to distinguish log messages between multiple instances of a object. (Bitbake rev: 5f363e4a9636b902229c257484ae0b479aedca65) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
f302039e0e
commit
7dffeb6ffd
@@ -104,6 +104,14 @@ logger.setLevel(logging.DEBUG - 2)
|
|||||||
|
|
||||||
mainlogger = logging.getLogger("BitBake.Main")
|
mainlogger = logging.getLogger("BitBake.Main")
|
||||||
|
|
||||||
|
class PrefixLoggerAdapter(logging.LoggerAdapter):
|
||||||
|
def __init__(self, prefix, logger):
|
||||||
|
super().__init__(logger, {})
|
||||||
|
self.__msg_prefix = prefix
|
||||||
|
|
||||||
|
def process(self, msg, kwargs):
|
||||||
|
return "%s%s" %(self.__msg_prefix, msg), kwargs
|
||||||
|
|
||||||
# This has to be imported after the setLoggerClass, as the import of bb.msg
|
# This has to be imported after the setLoggerClass, as the import of bb.msg
|
||||||
# can result in construction of the various loggers.
|
# can result in construction of the various loggers.
|
||||||
import bb.msg
|
import bb.msg
|
||||||
|
|||||||
Reference in New Issue
Block a user