Reputation: 2615
Here's a bit of code I'm running under:
import logging
logger = logging.getLogger("test.logger")
logger.setLevel(logging.DEBUG)
print("Effective logging level is {}".format(logger.getEffectiveLevel()))
And here's the output:
Effective logging level is 10
How do I print the level instead of the number?
Upvotes: 5
Views: 6759
Reputation: 1122182
Pass the numeric level to logging.getLevelName()
:
>>> import logging
>>> logging.getLevelName(10)
'DEBUG'
Does what it says on the tin:
Returns the textual representation of logging level lvl.
For your code that'd be:
print("Effective logging level is {}".format(
logging.getLevelName(logger.getEffectiveLevel())))
Upvotes: 9