Message ID | 20220919091312.894690-2-jose.quaresma@foundries.io |
---|---|
State | New |
Headers | show |
Series | [1/2] lib/bb: warning when the debug message is invalid | expand |
On Mon, Sep 19, 2022 at 4:14 AM Jose Quaresma <quaresma.jose@gmail.com> wrote: > > f68682a7 logging: Make bitbake logger compatible with python logger > introduces the "_debug_helper" that change the api of the debug logger as > they call now bbdebug always with level 1. Any old code that uses the old > syntax "debug(lvl, msg)" is broken if they don't call the main debug log. > > This issue can be replicated running "bitbake -D" with: > > from bb.fetch2 import logger > logger.debug(2, "I am alive") It was actually intentional to make it so that logger.debug() would match the standard Python logging API, because otherwise 3rd party code using the logger doesn't work, see f68682a7 ("logging: Make bitbake logger compatible with python logger") in bitbake. The correct code would be `logger.debug2("I am alive")` although I see we missed converting some of places that do that when we converted, which I think is my fault. Sorry. > > That one side effect is crashing the knotty: > > | Traceback (most recent call last): > | File "/srv/oe/bitbake/lib/bb/ui/knotty.py", line 685, in main > | event.msg = taskinfo['title'] + ': ' + event.msg > | TypeError: can only concatenate str (not "int") to str > > Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> > --- > lib/bb/__init__.py | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py > index 81b5a628..6378bce3 100644 > --- a/lib/bb/__init__.py > +++ b/lib/bb/__init__.py > @@ -45,7 +45,11 @@ class BBLoggerMixin(object): > self.debug = self._debug_helper > > def _debug_helper(self, *args, **kwargs): > - return self.bbdebug(1, *args, **kwargs) > + lvl = 1 > + if isinstance(args[0], int): > + lvl = args[0] > + args = args[1:] > + return self.bbdebug(lvl, *args, **kwargs) > > def debug2(self, *args, **kwargs): > return self.bbdebug(2, *args, **kwargs) > -- > 2.34.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#13979): https://lists.openembedded.org/g/bitbake-devel/message/13979 > Mute This Topic: https://lists.openembedded.org/mt/93777549/3616693 > Group Owner: bitbake-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [JPEWhacker@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py index 81b5a628..6378bce3 100644 --- a/lib/bb/__init__.py +++ b/lib/bb/__init__.py @@ -45,7 +45,11 @@ class BBLoggerMixin(object): self.debug = self._debug_helper def _debug_helper(self, *args, **kwargs): - return self.bbdebug(1, *args, **kwargs) + lvl = 1 + if isinstance(args[0], int): + lvl = args[0] + args = args[1:] + return self.bbdebug(lvl, *args, **kwargs) def debug2(self, *args, **kwargs): return self.bbdebug(2, *args, **kwargs)
f68682a7 logging: Make bitbake logger compatible with python logger introduces the "_debug_helper" that change the api of the debug logger as they call now bbdebug always with level 1. Any old code that uses the old syntax "debug(lvl, msg)" is broken if they don't call the main debug log. This issue can be replicated running "bitbake -D" with: from bb.fetch2 import logger logger.debug(2, "I am alive") That one side effect is crashing the knotty: | Traceback (most recent call last): | File "/srv/oe/bitbake/lib/bb/ui/knotty.py", line 685, in main | event.msg = taskinfo['title'] + ': ' + event.msg | TypeError: can only concatenate str (not "int") to str Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> --- lib/bb/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)