Repurpose -v/--verbose; add -t/--terse option (repmgr only)

repmgr and particularly repmgrd currently produce substantial
amounts of log output. Much of this is only useful when troubleshooting
or debugging.

Previously the -v/--verbose option just forced the log level to
INFO. With repmgrd this is pretty pointless - just set the log
level in the configuration file. With repmgr the configuration
file can be overriden by the new -L/--log-level option.

-v/--verbose now provides an additional, chattier/pedantic level
of logging ("Opening *this* logfile", "Executing *this* query",
"running in *this* loop") which is helpful for understanding
repmgr/repmgrd's behaviour, particularly for troubleshooting.
What additional verbose logging is generated will of course a
also depends on the log level set, so e.g. someone trying to
work out which configuration file is actually being opened
can use '--log-level=INFO --verbose' without being bothered
by an avalanche of extra verbose debugging output.

-t/--terse option will silence certain non-essential output, at
the moment any HINTs.

Note that -v/--verbose and -t/--terse are not mutually exclusive
(suggestions for better names welcome).
This commit is contained in:
Ian Barwick
2015-11-16 13:06:32 +09:00
parent acc0ffa81f
commit 807dcc1038
4 changed files with 88 additions and 25 deletions

View File

@@ -451,7 +451,7 @@ main(int argc, char **argv)
}
/*
* If no primary port (-p, --port) provided, explicitly set the
* If no primary port (-p/--port) provided, explicitly set the
* default PostgreSQL port.
*/
if (!runtime_options.masterport[0])
@@ -460,6 +460,13 @@ main(int argc, char **argv)
}
/*
* The logger is not yet set up as some configuration can be included
* in the configuration file; however if verbosity requested, we'll
* display the name of the configuration file we're attempting to open
* for the user's convenience as we might be opening the default
* ./repmgr.conf.
*/
if (runtime_options.verbose && runtime_options.config_file[0])
{
log_notice(_("opening configuration file: %s\n"),
@@ -521,7 +528,8 @@ main(int argc, char **argv)
logger_init(&options, progname(), options.loglevel, options.logfacility);
if (runtime_options.verbose)
logger_min_verbose(LOG_INFO);
logger_set_verbose();
/*
* Node configuration information is not needed for all actions, with
@@ -2531,7 +2539,11 @@ help(void)
printf(_("General options:\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -v, --verbose output verbose activity information\n"));
printf(_("\n"));
printf(_("Logging options:\n"));
printf(_(" -L, --log-level set log level (overrides configuration file)\n"));
printf(_(" -v, --verbose display additional log output (useful for debugging)\n"));
printf(_(" -t, --terse don't display hints and other non-critical output\n"));
printf(_("\n"));
printf(_("Connection options:\n"));
printf(_(" -d, --dbname=DBNAME database to connect to\n"));
@@ -2547,7 +2559,6 @@ help(void)
printf(_(" -R, --remote-user=USERNAME database server username for rsync\n"));
printf(_(" -F, --force force potentially dangerous operations to happen\n"));
printf(_(" --check-upstream-config verify upstream server configuration\n"));
printf(_(" -L, --log-level set log level (overrides configuration file)\n"));
printf(_("\n"));
printf(_("Command-specific configuration options:\n"));
printf(_(" -c, --fast-checkpoint (standby clone) force fast checkpoint\n"));