repmgr: always log to STDERR even if log facility defined

This commit is contained in:
Ian Barwick
2016-11-23 08:55:55 +09:00
parent 26f73686e5
commit b54f98ed8a
6 changed files with 19 additions and 10 deletions

View File

@@ -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)

View File

@@ -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)

9
log.c
View File

@@ -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)
{

2
log.h
View File

@@ -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);

View File

@@ -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();

View File

@@ -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();