Преглед изворни кода

Merge branch 'master' of github.com:Kozea/radicale

Guillaume Ayoub пре 11 година
родитељ
комит
4795b004b0
2 измењених фајлова са 15 додато и 5 уклоњено
  1. 14 5
      radicale/log.py
  2. 1 0
      radicale/storage/multifilesystem.py

+ 14 - 5
radicale/log.py

@@ -28,6 +28,7 @@ import os
 import sys
 import logging
 import logging.config
+import signal
 
 from . import config
 
@@ -35,6 +36,14 @@ from . import config
 LOGGER = logging.getLogger()
 
 
+def configure_from_file(filename, debug):
+    logging.config.fileConfig(filename)
+    if debug:
+        LOGGER.setLevel(logging.DEBUG)
+        for handler in LOGGER.handlers:
+            handler.setLevel(logging.DEBUG)
+
+
 def start():
     """Start the logging according to the configuration."""
     filename = os.path.expanduser(config.get("logging", "config"))
@@ -42,11 +51,11 @@ def start():
 
     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)
+        configure_from_file(filename, debug)
+        # Reload config on SIGHUP
+        def handler(signum, frame):
+            configure_from_file(filename, debug)
+        signal.signal(signal.SIGHUP, handler)
     else:
         # Default configuration, standard output
         handler = logging.StreamHandler(sys.stdout)

+ 1 - 0
radicale/storage/multifilesystem.py

@@ -60,6 +60,7 @@ class Collection(filesystem.Collection):
 
     def delete(self):
         shutil.rmtree(self._path)
+        os.remove(self._props_path)
 
     def remove(self, name):
         if os.path.exists(os.path.join(self._path, name)):