repmgr: add option --log-to-file; remove timestamp from log output by default

Log lines will still be prefixed with timestamp if `-log-to-file` used.
This commit is contained in:
Ian Barwick
2016-12-05 14:09:41 +09:00
parent 9788b2bd29
commit 7cc0400c03
4 changed files with 95 additions and 62 deletions

View File

@@ -232,6 +232,7 @@ main(int argc, char **argv)
{"no-upstream-connection", no_argument, NULL, OPT_NO_UPSTREAM_CONNECTION},
{"copy-external-config-files", optional_argument, NULL, OPT_COPY_EXTERNAL_CONFIG_FILES},
{"wait-sync", optional_argument, NULL, OPT_REGISTER_WAIT},
{"log-to-file", no_argument, NULL, OPT_LOG_TO_FILE},
{"version", no_argument, NULL, 'V'},
/* Following options for internal use */
{"cluster", required_argument, NULL, OPT_CLUSTER},
@@ -544,6 +545,10 @@ main(int argc, char **argv)
runtime_options.wait_register_sync_seconds = repmgr_atoi(optarg, "--wait-sync", &cli_errors, false);
}
break;
case OPT_LOG_TO_FILE:
runtime_options.log_to_file = true;
logger_output_mode = OM_DAEMON;
break;
case OPT_CONFIG_ARCHIVE_DIR:
strncpy(runtime_options.config_archive_dir, optarg, MAXLEN);
break;
@@ -6307,6 +6312,7 @@ do_help(void)
printf(_("\n"));
printf(_("Logging options:\n"));
printf(_(" -L, --log-level set log level (overrides configuration file; default: NOTICE)\n"));
printf(_(" --log-to-file log to file (or logging facility) defined in repmgr.conf\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"));