فهرست منبع

Print a debug message when the logging config file doesn't exist

Felix Lange 12 سال پیش
والد
کامیت
b737d17172
1فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 9 5
      radicale/log.py

+ 9 - 5
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)