1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Filter logged command options based on the command definition.

Previously, options were being filtered based on what was currently valid.  For chained commands (e.g. backup then expire) some options may be valid for the first command but not the second.

Filter based on the command definition rather than what is currently valid to avoid logging options that are not valid for subsequent commands.  This reduces the number of options logged and will hopefully help avoid confusion and expect log churn.
This commit is contained in:
David Steele
2019-11-14 16:48:41 -05:00
parent c5b76d213b
commit 3b879c2cb3
6 changed files with 36 additions and 24 deletions

View File

@ -57,6 +57,9 @@ cmdBegin(bool logOption)
{
strCatFmt(info, " %s:", PROJECT_VERSION);
// Get command define id used to determine which options are valid for this command
ConfigDefineCommand commandDefId = cfgCommandDefIdFromId(cfgCommand());
// Add command parameters if they exist
const StringList *commandParamList = cfgCommandParam();
@ -83,8 +86,10 @@ cmdBegin(bool logOption)
// Loop though options and add the ones that are interesting
for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++)
{
// Skip the option if it is not valid
if (!cfgOptionValid(optionId))
// Skip the option if not valid for this command. Generally only one command runs at a time, but sometimes
// commands are chained together (e.g. backup and expire) and the second command may not use all the options of
// the first command. Displaying them is harmless but might cause confusion.
if (!cfgDefOptionValid(commandDefId, cfgOptionDefIdFromId(optionId)))
continue;
// If option was negated