Use getattr to get numeric logging level.

It turns out it was a bad idea to use logging._nameToLevel since that
doesn't exist in python 3.3.
This commit is contained in:
Florian Bruhin 2014-05-26 09:00:45 +02:00
parent 323484496a
commit bb9f301410

View File

@ -57,9 +57,8 @@ def init_log(args):
else args.logfilter.split(',')) else args.logfilter.split(','))
level = 'DEBUG' if args.debug else args.loglevel.upper() level = 'DEBUG' if args.debug else args.loglevel.upper()
try: try:
# pylint: disable=protected-access numeric_level = getattr(logging, level)
numeric_level = logging._nameToLevel[level] except AttributeError:
except KeyError:
raise ValueError("Invalid log level: {}".format(args.loglevel)) raise ValueError("Invalid log level: {}".format(args.loglevel))
simple_fmt = '{levelname}: {message}' simple_fmt = '{levelname}: {message}'
extended_fmt = ('{asctime:8} {levelname:8} {name:10} {module}:{funcName}:' extended_fmt = ('{asctime:8} {levelname:8} {name:10} {module}:{funcName}:'