Dump the dss configuration on startup and on SIGHUP.
authorAndre Noll <maan@systemlinux.org>
Fri, 28 Aug 2009 11:42:51 +0000 (13:42 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 28 Aug 2009 11:47:30 +0000 (13:47 +0200)
This makes it possible to look at the current dss configuration
(which may differ from what is contained in the config file).

This feature is handy for the users of dss and it helps to debug the
dss code.

dss.c

diff --git a/dss.c b/dss.c
index a233c11..c5f636c 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -888,7 +888,6 @@ static int parse_config_file(int override)
                log_welcome(conf.loglevel_arg);
        }
        DSS_DEBUG_LOG("loglevel: %d\n", conf.loglevel_arg);
-//     cmdline_parser_dump(logfile? logfile : stdout, &conf);
        ret = config_file_exists;
 out:
        free(config_file);
@@ -903,14 +902,24 @@ static int change_to_dest_dir(void)
        return dss_chdir(conf.dest_dir_arg);
 }
 
+static void dump_dss_config(const char *msg)
+{
+       if (conf.loglevel_arg > INFO)
+               return;
+       DSS_INFO_LOG("%s\n", msg);
+       cmdline_parser_dump(logfile? logfile : stderr, &conf);
+}
+
 static int handle_sighup(void)
 {
        int ret;
 
-       DSS_NOTICE_LOG("SIGHUP\n");
+       DSS_NOTICE_LOG("SIGHUP, re-reading config\n");
+       dump_dss_config("current config");
        ret = parse_config_file(1);
        if (ret < 0)
                return ret;
+       dump_dss_config("new config");
        invalidate_next_snapshot_time();
        return change_to_dest_dir();
 }
@@ -1315,6 +1324,7 @@ int main(int argc, char **argv)
        }
        if (conf.daemon_given)
                daemon_init();
+       dump_dss_config("dss configuration");
        ret = change_to_dest_dir();
        if (ret < 0)
                goto out;