Consider the following example:
import logging
from loguru import logger
logger.debug("Debug with `logger.debug()`")
logger.log(logging.DEBUG, "Debug with `logger.log(logging.DEBUG)`")
logger.log("DEBUG", "Debug with `logger.log('DEBUG')`")
If I run this with loguru==0.7.3, I get the following output:
2025-10-30 09:34:32.031 | DEBUG | __main__:<module>:5 - Debug with `logger.debug()`
2025-10-30 09:34:32.031 | Level 10 | __main__:<module>:6 - Debug with `logger.log(logging.DEBUG)`
2025-10-30 09:34:32.031 | DEBUG | __main__:<module>:7 - Debug with `logger.log('DEBUG')`
But I expected:
2025-10-30 09:34:32.031 | DEBUG | __main__:<module>:5 - Debug with `logger.debug()`
2025-10-30 09:34:32.031 | DEBUG | __main__:<module>:6 - Debug with `logger.log(logging.DEBUG)`
2025-10-30 09:34:32.031 | DEBUG | __main__:<module>:7 - Debug with `logger.log('DEBUG')`
Since the logger.log() method is annotated to accept int | string, I would have expected the level name to be DEBUG if the level number 10 for debug is supplied.
Is that expected behaviour?
I am happy to provide a fix via a PR for this 🙂
Consider the following example:
If I run this with
loguru==0.7.3, I get the following output:But I expected:
Since the
logger.log()method is annotated to acceptint | string, I would have expected the level name to beDEBUGif the level number 10 for debug is supplied.Is that expected behaviour?
I am happy to provide a fix via a PR for this 🙂