From 6b5db413c515309a2e0659013874f231a0d6c8d3 Mon Sep 17 00:00:00 2001 From: Lukasz Langa Date: Mon, 9 May 2011 16:43:41 +0200 Subject: [PATCH] logging and debugging fixes * optparse values may not be strings, ConfigParser requires strings * forcing DEBUG level should work for all handlers regardless of configuration source (file, command line options) --- radicale.py | 4 ++-- radicale/log.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/radicale.py b/radicale.py index 7802576..8ac9bdb 100755 --- a/radicale.py +++ b/radicale.py @@ -81,10 +81,10 @@ for option in parser.option_list: if key: section = "logging" if key == "debug" else "server" value = getattr(options, key) - radicale.config.set(section, key, value) + radicale.config.set(section, key, str(value)) # Start logging -radicale.log.start(options.debug) +radicale.log.start() # Fork if Radicale is launched as daemon if options.daemon: diff --git a/radicale/log.py b/radicale/log.py index 3d36f9f..19ec046 100644 --- a/radicale/log.py +++ b/radicale/log.py @@ -35,10 +35,8 @@ from radicale import config LOGGER = logging.getLogger() FILENAME = os.path.expanduser(config.get("logging", "config")) -def start(debug=False): +def start(): """Start the logging according to the configuration.""" - if debug: - LOGGER.setLevel(logging.DEBUG) if os.path.exists(FILENAME): # Configuration taken from file @@ -48,3 +46,8 @@ def start(debug=False): handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter("%(message)s")) LOGGER.addHandler(handler) + + if config.getboolean("logging", "debug"): + LOGGER.setLevel(logging.DEBUG) + for handler in LOGGER.handlers: + handler.setLevel(logging.DEBUG)