From ada23997a99e4be91b3cc9e58f9c3b3e96ac1a47 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sun, 7 Jul 2013 15:07:21 +0200 Subject: [PATCH 1/2] Resolve logging configuration file when logging is started --- radicale/log.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/radicale/log.py b/radicale/log.py index b81853a..b1554f3 100644 --- a/radicale/log.py +++ b/radicale/log.py @@ -33,14 +33,14 @@ from . import config LOGGER = logging.getLogger() -FILENAME = os.path.expanduser(config.get("logging", "config")) - def start(): + filename = os.path.expanduser(config.get("logging", "config")) + """Start the logging according to the configuration.""" - if os.path.exists(FILENAME): + if os.path.exists(filename): # Configuration taken from file - logging.config.fileConfig(FILENAME) + logging.config.fileConfig(filename) else: # Default configuration, standard output handler = logging.StreamHandler(sys.stdout) From b737d17172266b526fe947f484038ec01ac3b729 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sun, 7 Jul 2013 15:48:14 +0200 Subject: [PATCH 2/2] Print a debug message when the logging config file doesn't exist --- radicale/log.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/radicale/log.py b/radicale/log.py index b1554f3..0135a0b 100644 --- a/radicale/log.py +++ b/radicale/log.py @@ -36,18 +36,22 @@ LOGGER = logging.getLogger() def start(): filename = os.path.expanduser(config.get("logging", "config")) + debug = config.getboolean("logging", "debug") """Start the logging according to the configuration.""" if os.path.exists(filename): # Configuration taken from file logging.config.fileConfig(filename) + if debug: + LOGGER.setLevel(logging.DEBUG) + for handler in LOGGER.handlers: + handler.setLevel(logging.DEBUG) else: # Default configuration, standard output 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) + if debug: + LOGGER.setLevel(logging.DEBUG) + LOGGER.debug("Logging configuration file '%s' not found, using stdout." + % filename)