diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-16 09:46:46 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-17 17:50:40 +0000 |
commit | 7bd40e3003a043e3cb7efc276681054b563b5e7b (patch) | |
tree | 160fb5b91bb2d2356ae62c0538486d109f9b2523 /lib/bb/__init__.py | |
parent | fdf6ebc8b603fcfd3ed7c64baf486a4adabd25be (diff) | |
download | bitbake-7bd40e3003a043e3cb7efc276681054b563b5e7b.tar.gz |
msg: Add bb.warnonce() and bb.erroronce() log methods
This adds a log level and logging function call to use it where the
warning or error will only be displayed once, regardless of how many
times the message is logged.
This has to be done either in the cooker or on the UI side. I've opted
for the UI side since display control is really a UI issue but it uses
a common library filter function to enable it which can be reused
elsewhere.
The knotty message displayed as the build summary is tweaked to
make sense when the numbers won't match since it will still count
the number of times it was logged and this is probably helpful
for debugging in some cases so I've deliberately left it that way.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/__init__.py')
-rw-r--r-- | lib/bb/__init__.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py index e01b8d525..269f65edc 100644 --- a/lib/bb/__init__.py +++ b/lib/bb/__init__.py @@ -71,6 +71,13 @@ class BBLoggerMixin(object): def verbnote(self, msg, *args, **kwargs): return self.log(logging.INFO + 2, msg, *args, **kwargs) + def warnonce(self, msg, *args, **kwargs): + return self.log(logging.WARNING - 1, msg, *args, **kwargs) + + def erroronce(self, msg, *args, **kwargs): + return self.log(logging.ERROR - 1, msg, *args, **kwargs) + + Logger = logging.getLoggerClass() class BBLogger(Logger, BBLoggerMixin): def __init__(self, name, *args, **kwargs): @@ -157,9 +164,15 @@ def verbnote(*args): def warn(*args): mainlogger.warning(''.join(args)) +def warnonce(*args): + mainlogger.warnonce(''.join(args)) + def error(*args, **kwargs): mainlogger.error(''.join(args), extra=kwargs) +def erroronce(*args): + mainlogger.erroronce(''.join(args)) + def fatal(*args, **kwargs): mainlogger.critical(''.join(args), extra=kwargs) raise BBHandledException() |