Open ryan-umbra opened 1 month ago
Hey @ryan-umbra.
I think your issue is similar to https://github.com/Delgan/loguru/issues/1149.
Basically, rich
uses standard logging
levels and isn't aware of the Loguru ones. Therefore, you need to register your TEST
level with logging.addLevelName()
:
logging.addLevelName(15, "TEST")
Hey there, I am running into (what I am pretty sure is) a bug when adding a custom log level and using Rich logging. For some reason when I add a custom log level in loguru with
logger.add(...)
, and haveshow_levels=True
in myRichHandler
, the levels appear as "Level X" - where "X" is the value of the custom level - instead of the level name (see attached). The bummer about this is if I am able to haveshow_levels=True
, then Rich automatically pads the levels, and gives them color. The simplest way to reproduce this bug:My workaround to this is to have
show_levels=False
in myRichHandler
then include level in my loguru format with"{level} {message}"
. I know I can pad the level which is nice, but it won't color them even if I do"<level>{level}</level>"
unfortunately.I have looked through a lot of issue pages and not seen one that matches this issue. The closes was this post and while the issue is similar, the problem seems quite different especially since they are not using Rich.
I have tried a few other workarounds too. What I discussed here I think is the clearest semblance of a bug and simplest (yet not ideal) workaround. Any help with this is greatly appreciated!
I am using loguru 0.7.2 and rich 12.6.0
BadLogLevel