Skip to content

Commit

Permalink
logging and debugging fixes
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
ambv committed May 9, 2011
1 parent 4212f6d commit 6b5db41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions radicale.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
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:
Expand Down
9 changes: 6 additions & 3 deletions radicale/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
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
Expand All @@ -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)

0 comments on commit 6b5db41

Please sign in to comment.