From dac63330e6879a0354449c8ad52f09a888d49d27 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 16 Feb 2022 09:46:46 -0600 Subject: bitbake: 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. (Bitbake rev: 7bd40e3003a043e3cb7efc276681054b563b5e7b) Signed-off-by: Richard Purdie Signed-off-by: Joshua Watt Signed-off-by: Richard Purdie --- bitbake/lib/bb/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'bitbake/lib/bb/__init__.py') diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py index e01b8d5256..269f65edce 100644 --- a/bitbake/lib/bb/__init__.py +++ b/bitbake/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() -- cgit v1.2.3-54-g00ecf