mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
Make verbose command line option useful on top of
the new logging infrastructure.
This commit is contained in:
8
config.c
8
config.c
@@ -30,10 +30,14 @@ parse_config(const char* config_file, t_configuration_options* options)
|
|||||||
|
|
||||||
FILE *fp = fopen (config_file, "r");
|
FILE *fp = fopen (config_file, "r");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since some commands don't require a config file at all, not
|
||||||
|
* having one isn't necessarily a problem.
|
||||||
|
*/
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("Could not find configuration file '%s'\n"), config_file);
|
fprintf(stderr, _("Did not find the configuration file '%s', continuing\n"), config_file);
|
||||||
exit(ERR_BAD_CONFIG);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
|
|||||||
11
log.c
11
log.c
@@ -130,6 +130,17 @@ bool logger_shutdown(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set a minimum logging level. Intended for command line verbosity
|
||||||
|
* options, which might increase requested logging over what's specified
|
||||||
|
* in the regular configuration file.
|
||||||
|
*/
|
||||||
|
void logger_min_verbose(int minimum)
|
||||||
|
{
|
||||||
|
if (log_level < minimum)
|
||||||
|
log_level = minimum;
|
||||||
|
}
|
||||||
|
|
||||||
int detect_log_level(const char* level)
|
int detect_log_level(const char* level)
|
||||||
{
|
{
|
||||||
if (!strcmp(level, "DEBUG"))
|
if (!strcmp(level, "DEBUG"))
|
||||||
|
|||||||
1
log.h
1
log.h
@@ -111,6 +111,7 @@
|
|||||||
/* Logger initialisation and shutdown */
|
/* Logger initialisation and shutdown */
|
||||||
bool logger_shutdown(void);
|
bool logger_shutdown(void);
|
||||||
bool logger_init(const char* ident, const char* level, const char* facility);
|
bool logger_init(const char* ident, const char* level, const char* facility);
|
||||||
|
void logger_min_verbose(int minimum);
|
||||||
|
|
||||||
extern int log_type;
|
extern int log_type;
|
||||||
extern int log_level;
|
extern int log_level;
|
||||||
|
|||||||
22
repmgr.c
22
repmgr.c
@@ -211,7 +211,7 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
if (runtime_options.host[0])
|
if (runtime_options.host[0])
|
||||||
{
|
{
|
||||||
log_err(_("Conflicting parameters you can't use -h while providing a node separately.\n"));
|
log_err(_("Conflicting parameters: you can't use -h while providing a node separately.\n"));
|
||||||
usage();
|
usage();
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ main(int argc, char **argv)
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_err(_("%s: too many command-line arguments (first is \"%s\")\n"),
|
log_err(_("%s: too many command-line arguments (first extra is \"%s\")\n"),
|
||||||
progname, argv[optind + 1]);
|
progname, argv[optind + 1]);
|
||||||
usage();
|
usage();
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
@@ -243,7 +243,7 @@ main(int argc, char **argv)
|
|||||||
strncpy(runtime_options.dbname, DEFAULT_DBNAME, MAXLEN);
|
strncpy(runtime_options.dbname, DEFAULT_DBNAME, MAXLEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the configuration file: repmgr.conf */
|
/* Read the configuration file, normally repmgr.conf */
|
||||||
if (!runtime_options.config_file[0])
|
if (!runtime_options.config_file[0])
|
||||||
strncpy(runtime_options.config_file, DEFAULT_CONFIG_FILE, MAXLEN);
|
strncpy(runtime_options.config_file, DEFAULT_CONFIG_FILE, MAXLEN);
|
||||||
|
|
||||||
@@ -261,7 +261,17 @@ main(int argc, char **argv)
|
|||||||
keywords[5] = NULL;
|
keywords[5] = NULL;
|
||||||
values[5] = NULL;
|
values[5] = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
logger_init(progname, options.loglevel, options.logfacility);
|
logger_init(progname, options.loglevel, options.logfacility);
|
||||||
|
if (runtime_options.verbose)
|
||||||
|
logger_min_verbose(LOG_INFO);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Node configuration information is not needed for all actions,
|
* Node configuration information is not needed for all actions,
|
||||||
@@ -592,7 +602,6 @@ do_standby_register(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Now register the standby */
|
/* Now register the standby */
|
||||||
if (runtime_options.force)
|
if (runtime_options.force)
|
||||||
{
|
{
|
||||||
@@ -724,6 +733,7 @@ do_standby_clone(void)
|
|||||||
values[1] = runtime_options.masterport;
|
values[1] = runtime_options.masterport;
|
||||||
|
|
||||||
/* We need to connect to check configuration and start a backup */
|
/* We need to connect to check configuration and start a backup */
|
||||||
|
log_info(_("%s connecting to master database\n"), progname);
|
||||||
conn = PQconnectdbParams(keywords, values, true);
|
conn = PQconnectdbParams(keywords, values, true);
|
||||||
if (!conn)
|
if (!conn)
|
||||||
{
|
{
|
||||||
@@ -733,6 +743,7 @@ do_standby_clone(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* primary should be v9 or better */
|
/* primary should be v9 or better */
|
||||||
|
log_info(_("%s connected to master, checking its state\n"), progname);
|
||||||
pg_version(conn, master_version);
|
pg_version(conn, master_version);
|
||||||
if (strcmp(master_version, "") == 0)
|
if (strcmp(master_version, "") == 0)
|
||||||
{
|
{
|
||||||
@@ -1562,7 +1573,8 @@ check_parameters_for_action(const int action)
|
|||||||
{
|
{
|
||||||
log_notice("Only command line parameters for the connection "
|
log_notice("Only command line parameters for the connection "
|
||||||
"to the master are used when issuing a STANDBY CLONE command. "
|
"to the master are used when issuing a STANDBY CLONE command. "
|
||||||
"The passed configuration file is neither required nor used\n");
|
"The passed configuration file is neither required nor used for "
|
||||||
|
"its node configuration portions\n\n");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* To clone a master into a standby we need connection parameters
|
* To clone a master into a standby we need connection parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user