From c54bb73fb2d5db69bb7de13375164fdcb309e86c Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 31 May 2018 15:30:26 +0900 Subject: [PATCH] If --dry-run specified, ensure minimum log level is INFO When executed with --dry-run, repmgr outputs detail about what would happen using log level INFO. If the log_level is configured to NOTICE or higher, it's possible some or all of the --dry-run output might not be displayed. Addresses GitHub #441. --- log.c | 7 +++++++ log.h | 1 + repmgr-client.c | 12 +++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/log.c b/log.c index a5afe072..fb2cb507 100644 --- a/log.c +++ b/log.c @@ -329,6 +329,13 @@ logger_set_terse(void) } +void +logger_set_min_level(int min_log_level) +{ + if (min_log_level > log_level) + log_level = min_log_level; +} + int detect_log_level(const char *level) { diff --git a/log.h b/log.h index 7a6ca9bb..fa232656 100644 --- a/log.h +++ b/log.h @@ -128,6 +128,7 @@ bool logger_shutdown(void); void logger_set_verbose(void); void logger_set_terse(void); +void logger_set_min_level(int min_log_level); void log_detail(const char *fmt,...) diff --git a/repmgr-client.c b/repmgr-client.c index fef8acbe..bb902789 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -1010,7 +1010,6 @@ main(int argc, char **argv) runtime_options.output_mode = OM_OPTFORMAT; } - /* * Check for configuration file items which can be overriden by runtime * options @@ -1068,6 +1067,17 @@ main(int argc, char **argv) if (runtime_options.terse) logger_set_terse(); + /* + * If --dry-run specified, ensure log_level is at least LOG_INFO, regardless + * of what's in the configuration file or -L/--log-level paremeter, otherwise + * some or output might not be displayed. + */ + if (runtime_options.dry_run == true) + { + logger_set_min_level(LOG_INFO); + } + + /* * Node configuration information is not needed for all actions, with * STANDBY CLONE being the main exception.