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)
This commit is contained in:
Lukasz Langa 2011-05-09 16:43:41 +02:00
parent 4212f6dfe0
commit 6b5db413c5
2 changed files with 8 additions and 5 deletions

View File

@ -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:

View File

@ -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)