Open mpenning opened 10 months ago
Hi @mpenning.
Sorry you're experiencing difficulties with Loguru, and thanks for the reproducible example. It boils down to the following:
from loguru import logger
class Foo:
@logger.catch(reraise=True)
def __repr__(self):
raise ValueError("Something went wrong")
if __name__ == "__main__":
foo = Foo()
print(foo)
It's definitely a problem with diagnose=True
which causes infinite recursion if the exception is raised in __repr__
, since v
can't be printed: https://github.com/Delgan/loguru/blob/dcf42d962567723c0195bb8b2bb6fd764ecf41ae/loguru/_better_exceptions.py#L331-L335
I'll try to implement a fix. In the meantime, I advise to use diagnose=False
or remove @logger.catch()
decorator from __repr__()
methods.
@logger.catch(reraise=True)
My problem is if I hit a bug in certain methods, I get an infinite traceback from loguru. I love loguru when it works, but digging into the infinite recursion is a serious drag on my development because even with a multi-thousand-line scrollback buffer, I still can't hit control-c fast enough to interrupt the infinite loop of loguru messages and find the real cause of the problem (i.e. I have two problems, loguru inifinte recursion and the ciscoconfparse2 bug that caused it).
Is there a way to get loguru to stop printing tracebacks in an infinite loop?
You can reproduce the infinite recursion loop as follows:
loguru==0.7.2
cd ciscoconfparse2
1a7b88d72c5a86a673ba8d4ed18316036c65fded