Fix tweak_logging_levels().

This commit is contained in:
Pedro Algarvio 2010-12-07 14:21:45 +00:00
parent 49e10ea0cf
commit eeed72a977

View File

@ -39,8 +39,7 @@
import os import os
import logging import logging
import inspect import inspect
import pkg_resources from deluge import common
from deluge import common, component
from twisted.internet import defer from twisted.internet import defer
from twisted.python.log import PythonLoggingObserver from twisted.python.log import PythonLoggingObserver
@ -119,6 +118,7 @@ class Logging(LoggingLoggerClass):
levels = { levels = {
"info": logging.INFO, "info": logging.INFO,
"warn": logging.WARNING,
"warning": logging.WARNING, "warning": logging.WARNING,
"error": logging.ERROR, "error": logging.ERROR,
"none": logging.CRITICAL, "none": logging.CRITICAL,
@ -202,13 +202,15 @@ def tweak_logging_levels():
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
log.warn("logging.conf found! tweaking logging levels from %s", log.warn("logging.conf found! tweaking logging levels from %s",
logging_config_file) logging_config_file)
for line in open(logging_config_file, 'r'): for line in open(logging_config_file, 'r').readlines():
if line.strip().startswith("#"): if line.strip().startswith("#"):
continue continue
name, level = line.strip().split(':') name, level = line.strip().split(':')
if level in levels: if level not in levels:
log.warn("Setting logger \"%s\" to logging level \"%s\"", name, level) continue
logging.getLogger(name).setLevel(levels.get(level))
log.warn("Setting logger \"%s\" to logging level \"%s\"", name, level)
setLoggerLevel(level, name)
def setLoggerLevel(level, logger_name=None): def setLoggerLevel(level, logger_name=None):