Using getEffectiveLevel
I can query what the logger current level is:
import logging
logger = logging.getLogger('top')
level_number = logger.getEffectiveLevel()
The returned by getEffectiveLevel
method value is the integer. I wonder if there is a way of querying a corresponding the string value such as "DEBUG" or "INFO" instead of an integer.
If you place the result of a call to the object's getEffectiveLevel()
method into the logging
module's getLevelName()
class method, you get returned to you the string representation of the level:
import logging
log = logging.getLogger('blah')
str_level = logging.getLevelName(log.getEffectiveLevel())
print(str_level)
Output:
WARNING
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With