diff --git a/HISTORY b/HISTORY index d0f6ff17..7ed733f3 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +3.2.2 2016-11-23 + repmgr: always log to STDERR even if log facility defined (Ian) + 3.2.1 2016-10-24 repmgr: require a valid repmgr cluster name unless -F/--force supplied (Ian) diff --git a/config.c b/config.c index 8376877a..69bb2f07 100644 --- a/config.c +++ b/config.c @@ -752,7 +752,7 @@ reload_config(t_configuration_options *orig_options) { log_notice(_("restarting logging with changed parameters\n")); logger_shutdown(); - logger_init(orig_options, progname()); + logger_init(orig_options, progname(), false); } if (config_changed == true) diff --git a/log.c b/log.c index fd5d7ffb..a498e5f3 100644 --- a/log.c +++ b/log.c @@ -142,7 +142,7 @@ log_verbose(int level, const char *fmt, ...) bool -logger_init(t_configuration_options *opts, const char *ident) +logger_init(t_configuration_options *opts, const char *ident, bool stderr_only) { char *level = opts->loglevel; char *facility = opts->logfacility; @@ -176,6 +176,13 @@ logger_init(t_configuration_options *opts, const char *ident) stderr_log_warning(_("Invalid log level \"%s\" (available values: DEBUG, INFO, NOTICE, WARNING, ERR, ALERT, CRIT or EMERG)\n"), level); } + /* + * STDERR only logging requested - finish here without setting up any further + * logging facility. + */ + if (stderr_only == true) + return true; + if (facility && *facility) { diff --git a/log.h b/log.h index 58f7b459..23423869 100644 --- a/log.h +++ b/log.h @@ -116,7 +116,7 @@ int detect_log_level(const char *level); /* Logger initialisation and shutdown */ -bool logger_init(t_configuration_options * opts, const char *ident); +bool logger_init(t_configuration_options * opts, const char *ident, bool stderr_only); bool logger_shutdown(void); diff --git a/repmgr.c b/repmgr.c index 4425671f..f7fe0b53 100644 --- a/repmgr.c +++ b/repmgr.c @@ -832,14 +832,12 @@ main(int argc, char **argv) } /* - * Initialize the logger. If verbose command line parameter was input, - * make sure that the log level is at least INFO. This is mainly useful - * for STANDBY CLONE. That doesn't require a configuration file where a - * logging level might be specified at, but it often requires detailed - * logging to troubleshoot problems. + * Initialize the logger. We'll request STDERR logging only to ensure the + * repmgr command never has its output diverted to a logging facility, + * which makes little sense for a command line program. */ - logger_init(&options, progname()); + logger_init(&options, progname(), true); if (runtime_options.verbose) logger_set_verbose(); diff --git a/repmgrd.c b/repmgrd.c index 037d820f..f8beb50b 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -246,7 +246,8 @@ main(int argc, char **argv) strerror(errno)); } - logger_init(&local_options, progname()); + logger_init(&local_options, progname(), false); + if (verbose) logger_set_verbose();