diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2020-06-05 22:15:32 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-10 12:30:01 +0100 |
commit | 7dffeb6ffd82e0cee1ab761ab0f2b0415bddb349 (patch) | |
tree | 4dff206f3e59bc0d22676f0bf28efffbbf6255d0 /bitbake | |
parent | f302039e0e6643c729a6f6fb677fa48ce7247da3 (diff) | |
download | poky-7dffeb6ffd82e0cee1ab761ab0f2b0415bddb349.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/__init__.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py index cd53603a47..4e2f97b234 100644 --- a/bitbake/lib/bb/__init__.py +++ b/bitbake/lib/bb/__init__.py | |||
@@ -104,6 +104,14 @@ logger.setLevel(logging.DEBUG - 2) | |||
104 | 104 | ||
105 | mainlogger = logging.getLogger("BitBake.Main") | 105 | mainlogger = logging.getLogger("BitBake.Main") |
106 | 106 | ||
107 | class PrefixLoggerAdapter(logging.LoggerAdapter): | ||
108 | def __init__(self, prefix, logger): | ||
109 | super().__init__(logger, {}) | ||
110 | self.__msg_prefix = prefix | ||
111 | |||
112 | def process(self, msg, kwargs): | ||
113 | return "%s%s" %(self.__msg_prefix, msg), kwargs | ||
114 | |||
107 | # This has to be imported after the setLoggerClass, as the import of bb.msg | 115 | # This has to be imported after the setLoggerClass, as the import of bb.msg |
108 | # can result in construction of the various loggers. | 116 | # can result in construction of the various loggers. |
109 | import bb.msg | 117 | import bb.msg |