From 17ab86f7ace7ba94c63676e46a4ed1c898bee261 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 19 Nov 2015 10:32:13 +0900 Subject: [PATCH] Don't display warnings about unused command line parameters in --terse mode --- repmgr.c | 16 +++++++++++++--- repmgr.h | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/repmgr.c b/repmgr.c index d0f2e066..d7bc7b5c 100644 --- a/repmgr.c +++ b/repmgr.c @@ -154,6 +154,7 @@ main(int argc, char **argv) {"rsync-only", no_argument, NULL, 'r'}, {"fast-checkpoint", no_argument, NULL, 'c'}, {"log-level", required_argument, NULL, 'L'}, + {"terse", required_argument, NULL, 't'}, {"initdb-no-pwprompt", no_argument, NULL, 1}, {"check-upstream-config", no_argument, NULL, 2}, {"recovery-min-apply-delay", required_argument, NULL, 3}, @@ -177,7 +178,7 @@ main(int argc, char **argv) /* Prevent getopt_long() from printing an error message */ opterr = 0; - while ((c = getopt_long(argc, argv, "?Vd:h:p:U:S:D:l:f:R:w:k:FWIvb:r:c:L:", long_options, + while ((c = getopt_long(argc, argv, "?Vd:h:p:U:S:D:l:f:R:w:k:FWIvb:r:c:L:t", long_options, &optindex)) != -1) { /* @@ -275,6 +276,8 @@ main(int argc, char **argv) } break; } + case 't': + runtime_options.terse = true; case 1: runtime_options.initdb_no_pwprompt = true; break; @@ -442,7 +445,7 @@ main(int argc, char **argv) exit_with_errors(); } - if (cli_warnings.head != NULL) + if (cli_warnings.head != NULL && runtime_options.terse == false) { print_error_list(&cli_warnings, LOG_WARNING); } @@ -534,9 +537,13 @@ main(int argc, char **argv) } logger_init(&options, progname(), options.loglevel, options.logfacility); + if (runtime_options.verbose) logger_set_verbose(); + if (runtime_options.terse) + logger_set_terse(); + /* * Node configuration information is not needed for all actions, with @@ -1354,6 +1361,9 @@ do_standby_clone(void) strncpy(local_config_file, master_config_file, MAXFILENAME); strncpy(local_hba_file, master_hba_file, MAXFILENAME); strncpy(local_ident_file, master_ident_file, MAXFILENAME); + + log_notice(_("setting data directory to: %s\n"), local_data_directory); + log_hint(_("use -D/--data-dir to explicitly specify a data directory")); } /* @@ -2955,7 +2965,7 @@ check_parameters_for_action(const int action) if (runtime_options.host[0] || runtime_options.masterport[0] || runtime_options.username[0] || runtime_options.dbname[0]) { - error_list_append(&cli_warnings _("master connection parameters not required when executing STANDBY REGISTER")); + error_list_append(&cli_warnings, _("master connection parameters not required when executing STANDBY REGISTER")); } if (runtime_options.dest_dir[0]) { diff --git a/repmgr.h b/repmgr.h index c2895bf6..21b5971f 100644 --- a/repmgr.h +++ b/repmgr.h @@ -73,6 +73,7 @@ typedef struct char superuser[MAXLEN]; char wal_keep_segments[MAXLEN]; bool verbose; + bool terse; bool force; bool wait_for_master; bool ignore_rsync_warn; @@ -92,7 +93,7 @@ typedef struct char recovery_min_apply_delay[MAXLEN]; } t_runtime_options; -#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, false, false, "", "", "", 0, "", "" } +#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, false, false, false, "", "", "", 0, "", "" } extern char repmgr_schema[MAXLEN];