Open abitrolly opened 4 years ago
The task is to make Python logging logger.setLevel() accept lowercase string. It already accepts uppercase 'DEBUG' string.
logging
logger.setLevel()
import logging logger = logging.getLogger(__name__) handler = logging.StreamHandler() logger.addHandler(handler) logger.setLevel('DEBUG') logger.debug('!!!')
Modifications need to be done to _checkLevel function.
_checkLevel
https://github.com/python/cpython/blob/8c0f0016e2d39f86589187db75012238c4e760e9/Lib/logging/__init__.py#L189-L198
def _checkLevel(level): if isinstance(level, int): rv = level elif str(level) == level: if level not in _nameToLevel: raise ValueError("Unknown level: %r" % level) rv = _nameToLevel[level] else: raise TypeError("Level not an integer or a valid string: %r" % level) return rv
Docs: https://docs.python.org/3/library/logging.html#logging.Logger.setLevel
The task is to make Python
logging
logger.setLevel()
accept lowercase string. It already accepts uppercase 'DEBUG' string.Modifications need to be done to
_checkLevel
function.https://github.com/python/cpython/blob/8c0f0016e2d39f86589187db75012238c4e760e9/Lib/logging/__init__.py#L189-L198