]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
client: Fix loglevel setting.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 17 Mar 2018 22:29:12 +0000 (23:29 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 30 Mar 2018 14:18:06 +0000 (16:18 +0200)
If --loglevel is given in the config file but not at the command line,
the value from the config file should be used. However, currently we
use the default value in this case. Moreover, client_parse_config()
sets the loglevel *after* it already printed some log messages.

This commit changes client_parse_config() to initialize the loglevel
pointer right after the command line and config file options have
been merged.

client_common.c

index 97d29f8fd09948b1e97972431df1f62ec30a4989..fce5483aee60da60e1db320812aa687c7c8c6f7b 100644 (file)
@@ -536,7 +536,6 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
        ret = lls(lls_parse(argc, argv, cmd, &lpr, &errctx));
        if (ret < 0)
                goto out;
-       ll = CLIENT_OPT_UINT32_VAL(LOGLEVEL, lpr);
        version_handle_flag("client", CLIENT_OPT_GIVEN(VERSION, lpr));
        handle_help_flag(lpr);
 
@@ -573,6 +572,9 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
                lpr = merged_lpr;
        }
        /* success */
+       ll = CLIENT_OPT_UINT32_VAL(LOGLEVEL, lpr);
+       if (loglevel)
+               *loglevel = ll;
        user = CLIENT_OPT_GIVEN(USER, lpr)?
                para_strdup(CLIENT_OPT_STRING_VAL(USER, lpr)) : para_logname();
 
@@ -596,8 +598,6 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
        ct->config_file = cf;
        ct->user = user;
        *ct_ptr = ct;
-       if (loglevel)
-               *loglevel = ll;
        ret = lls_num_inputs(lpr);
 out:
        free(home);