[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.50-90-g8664feb

Andreas Beckmann anbe at debian.org
Sat Apr 13 14:09:36 UTC 2013


The following commit has been merged in the develop branch:
commit 5f121d7e945f71366447d1ad6fdc64ff159e4f2d
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sun Apr 7 01:11:06 2013 +0200

    p-m: support switching the logfile while master is running
    
    start with logging to stderr and loglevel INFO until a section
    logfile is opened
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>

diff --git a/piuparts-master-backend.py b/piuparts-master-backend.py
index d8c0f6c..6ed2c05 100644
--- a/piuparts-master-backend.py
+++ b/piuparts-master-backend.py
@@ -41,15 +41,21 @@ CONFIG_FILE = "/etc/piuparts/piuparts.conf"
 DISTRO_CONFIG_FILE = "/etc/piuparts/distros.conf"
 
 
+log_handler = None
+
 def setup_logging(log_level, log_file_name):
     logger = logging.getLogger()
-    logger.setLevel(log_level)
+
+    global log_handler;
+    logger.removeHandler(log_handler)
 
     if log_file_name:
-        handler = logging.FileHandler(log_file_name)
+        log_handler = logging.FileHandler(log_file_name)
     else:
-        handler = logging.StreamHandler(sys.stderr)
-    logger.addHandler(handler)
+        log_handler = logging.StreamHandler(sys.stderr)
+
+    logger.addHandler(log_handler)
+    logger.setLevel(log_level)
 
 
 class Config(piupartslib.conf.Config):
@@ -315,6 +321,7 @@ class Master(Protocol):
 
 
 def main():
+    setup_logging(logging.INFO, None)
     # piuparts-master is always called by the slave with a section as argument
     if len(sys.argv) == 2:
         global_config = Config(section="global")

-- 
piuparts git repository



More information about the Piuparts-commits mailing list