ctdb-daemon: Avoid unnecessarily spamming the logs when in test mode
authorMartin Schwenke <martin@meltin.net>
Wed, 17 Oct 2018 10:24:07 +0000 (21:24 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 6 Nov 2018 06:16:14 +0000 (07:16 +0100)
Logging the logging location to syslog can be useful on production
systems when the configuration goes unexpectedly missing.  However, in
test mode this just adds noise to the logs on the test system.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdbd.c

index 9a8e0e8c3f47e6a7c83b316ee67e07bed37fbbfb..2377399b2ac0f69359a1caee6905f0b8abf93a25 100644 (file)
@@ -167,7 +167,7 @@ int main(int argc, const char *argv[])
        const char *ctdb_base;
        struct conf_context *conf;
        const char *logging_location;
-       const char *t;
+       const char *test_mode;
        bool ok;
 
        /*
@@ -238,6 +238,8 @@ int main(int argc, const char *argv[])
         * Logging setup/options
         */
 
+       test_mode = getenv("CTDB_TEST_MODE");
+
        /* Log to stderr (ignoring configuration) when running as interactive */
        if (interactive) {
                logging_location = "file:";
@@ -246,7 +248,7 @@ int main(int argc, const char *argv[])
                logging_location = logging_conf_location(conf);
        }
 
-       if (strcmp(logging_location, "syslog") != 0) {
+       if (strcmp(logging_location, "syslog") != 0 && test_mode == NULL) {
                /* This can help when CTDB logging is misconfigured */
                syslog(LOG_DAEMON|LOG_NOTICE,
                       "CTDB logging to location %s",
@@ -363,8 +365,7 @@ int main(int argc, const char *argv[])
         * Testing and debug options
         */
 
-       t = getenv("CTDB_TEST_MODE");
-       if (t != NULL) {
+       if (test_mode != NULL) {
                ctdb->do_setsched = false;
                ctdb->do_checkpublicip = false;
                fast_start = true;