repmgr: pass explicitly provided log level when executing repmgr remotely

This makes it possible to return log output when executing repmgr
remotely at a different level to the one defined in the remote
repmgr's repmgr.conf.

This is particularly useful when DEBUG output is required.
This commit is contained in:
Ian Barwick
2019-09-17 15:30:21 +09:00
parent 98e96f4375
commit 10f00b8822
4 changed files with 54 additions and 2 deletions

View File

@@ -4,6 +4,7 @@
repmgr: rename "repmgr daemon ..." commands to "repmgr service ..." (Ian)
repmgr: improve data directory check (Ian)
repmgr: improve extension check during "standby clone" (Ian)
repmgr: pass provided log level when executing repmgr remotely (Ian)
4.4 2019-06-27
repmgr: improve "daemon status" output (Ian)

View File

@@ -194,6 +194,22 @@ conninfo='host=node1 user=repmgr dbname=repmgr connect_timeout=2'</programlistin
been improved and error messages improved.
</para>
</listitem>
<listitem>
<para>
When executing &repmgr; remotely, if the &repmgr; log level was explicitly
provided (with <option>-L</option>/<option>--log-level</option>), that log level
will be passed to the remote &repmgr;.
</para>
<para>
This makes it possible to return log output when executing repmgr
remotely at a different level to the one defined in the remote
&repmgr;'s <filename>repmgr.conf</filename>.
</para>
<para>
This is particularly useful when <literal>DEBUG</literal> output is required.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>

View File

@@ -987,7 +987,19 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
make_remote_repmgr_path(&command, cell->node_info);
appendPQExpBufferStr(&command,
" cluster show --csv -L NOTICE --terse\"");
" cluster show --csv --terse");
/*
* Usually we'll want NOTICE as the log level, but if the user
* explicitly provided one with --log-level, that will be passed
* in the remote repmgr invocation.
*/
if (runtime_options.log_level[0] == '\0')
{
appendPQExpBufferStr(&command,
" -L NOTICE");
}
appendPQExpBufferChar(&command, '"');
log_verbose(LOG_DEBUG, "build_cluster_matrix(): executing:\n %s", command.data);
@@ -1175,7 +1187,18 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
make_remote_repmgr_path(&command, cell->node_info);
appendPQExpBufferStr(&command,
" cluster matrix --csv -L NOTICE --terse");
" cluster matrix --csv --terse");
/*
* Usually we'll want NOTICE as the log level, but if the user
* explicitly provided one with --log-level, that will be passed
* in the remote repmgr invocation.
*/
if (runtime_options.log_level[0] == '\0')
{
appendPQExpBufferStr(&command,
" -L NOTICE");
}
initPQExpBuffer(&command_output);

View File

@@ -3167,6 +3167,18 @@ make_remote_repmgr_path(PQExpBufferData *output_buf, t_node_info *remote_node_re
"%s -f %s ",
progname(),
remote_node_record->config_file);
/*
* If --log-level was explicitly supplied, pass that through
* to the remote repmgr client too.
*/
if (runtime_options.log_level[0] != '\0')
{
appendPQExpBuffer(output_buf,
" -L %s ",
runtime_options.log_level);
}
}