mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Suppress configuration file warnings if --terse is set
This commit is contained in:
18
config.c
18
config.c
@@ -22,7 +22,7 @@ static void tablespace_list_append(t_configuration_options *options, const char
|
||||
|
||||
static char *trim(char *s);
|
||||
|
||||
static void exit_with_errors(ItemList *config_errors, ItemList *config_warnings);
|
||||
static void exit_with_errors(ItemList *config_errors, ItemList *config_warnings, bool terse);
|
||||
|
||||
|
||||
void
|
||||
@@ -38,7 +38,7 @@ progname(void)
|
||||
}
|
||||
|
||||
bool
|
||||
load_config(const char *config_file, bool verbose, t_configuration_options *options, char *argv0)
|
||||
load_config(const char *config_file, bool verbose, bool terse, t_configuration_options *options, char *argv0)
|
||||
{
|
||||
struct stat stat_config;
|
||||
|
||||
@@ -156,12 +156,12 @@ load_config(const char *config_file, bool verbose, t_configuration_options *opti
|
||||
}
|
||||
}
|
||||
|
||||
return parse_config(options);
|
||||
return parse_config(options, terse);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
parse_config(t_configuration_options *options)
|
||||
parse_config(t_configuration_options *options, bool terse)
|
||||
{
|
||||
/* Collate configuration file errors here for friendlier reporting */
|
||||
static ItemList config_errors = { NULL, NULL };
|
||||
@@ -172,10 +172,10 @@ parse_config(t_configuration_options *options)
|
||||
/* errors found - exit after printing details, and any warnings */
|
||||
if (config_errors.head != NULL)
|
||||
{
|
||||
exit_with_errors(&config_errors, &config_warnings);
|
||||
exit_with_errors(&config_errors, &config_warnings, terse);
|
||||
}
|
||||
|
||||
if (config_warnings.head != NULL)
|
||||
if (terse == false && config_warnings.head != NULL)
|
||||
{
|
||||
ItemListCell *cell;
|
||||
|
||||
@@ -633,10 +633,11 @@ reload_config(t_configuration_options *orig_options)
|
||||
|
||||
/* TODO: don't emit warnings if --terse and no errors */
|
||||
static void
|
||||
exit_with_errors(ItemList *config_errors, ItemList *config_warnings)
|
||||
exit_with_errors(ItemList *config_errors, ItemList *config_warnings, bool terse)
|
||||
{
|
||||
ItemListCell *cell;
|
||||
|
||||
|
||||
log_error(_("following errors were found in the configuration file:"));
|
||||
|
||||
for (cell = config_errors->head; cell; cell = cell->next)
|
||||
@@ -644,7 +645,7 @@ exit_with_errors(ItemList *config_errors, ItemList *config_warnings)
|
||||
fprintf(stderr, " %s\n", cell->string);
|
||||
}
|
||||
|
||||
if (config_warnings->head != NULL)
|
||||
if (terse == false && config_warnings->head != NULL)
|
||||
{
|
||||
puts("");
|
||||
log_warning(_("the following problems were also found in the configuration file:"));
|
||||
@@ -653,6 +654,7 @@ exit_with_errors(ItemList *config_errors, ItemList *config_warnings)
|
||||
fprintf(stderr, " %s\n", cell->string);
|
||||
}
|
||||
}
|
||||
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
|
||||
4
config.h
4
config.h
@@ -129,8 +129,8 @@ typedef struct
|
||||
void set_progname(const char *argv0);
|
||||
const char *progname(void);
|
||||
|
||||
bool load_config(const char *config_file, bool verbose, t_configuration_options *options, char *argv0);
|
||||
bool parse_config(t_configuration_options *options);
|
||||
bool load_config(const char *config_file, bool verbose, bool terse, t_configuration_options *options, char *argv0);
|
||||
bool parse_config(t_configuration_options *options, bool terse);
|
||||
bool reload_config(t_configuration_options *orig_options);
|
||||
|
||||
|
||||
|
||||
@@ -325,6 +325,7 @@ main(int argc, char **argv)
|
||||
*/
|
||||
config_file_parsed = load_config(runtime_options.config_file,
|
||||
runtime_options.verbose,
|
||||
runtime_options.terse,
|
||||
&config_file_options,
|
||||
argv[0]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user