When using logger.catch with error codes from the standard logging library, the log level will be rendered incorrectly as below:
from logging import CRITICAL
from loguru import logger
@logger.catch(level=CRITICAL)
def error():
raise Exception
error()
2024-01-01 20:38:27.032 | Level 50 | __main__:<module>:11 - An error has been caught in function '<module>', process 'MainProcess' (80296), thread 'MainThread' (7921619712):
Traceback (most recent call last):
> File "/Users/jimmy/Desktop/dev/Enigma/test.py", line 11, in <module>
error()
└ <function error at 0x103c52d40>
File "/Users/jimmy/Desktop/dev/Enigma/test.py", line 8, in error
raise Exception
Exception
This behaviour however is fixed when passing a string in logger.catch, as the code snippets below:
from loguru import logger
@logger.catch(level="CRITICAL")
def error():
raise Exception
error()
2024-01-01 20:39:46.068 | CRITICAL | __main__:<module>:11 - An error has been caught in function '<module>', process 'MainProcess' (80376), thread 'MainThread' (7921619712):
Traceback (most recent call last):
> File "/Users/jimmy/Desktop/dev/Enigma/test.py", line 11, in <module>
error()
└ <function error at 0x1050f6d40>
File "/Users/jimmy/Desktop/dev/Enigma/test.py", line 8, in error
raise Exception
Exception
Is this an intended feature or a bug? Many thanks for the answer.
When using
logger.catchwith error codes from the standard logging library, the log level will be rendered incorrectly as below:This behaviour however is fixed when passing a string in
logger.catch, as the code snippets below:Is this an intended feature or a bug? Many thanks for the answer.