mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
In pg_upgrade, add various logging improvements:
add ability to control permissions of created files have psql echo its queries for easier debugging output four separate log files, and delete them on success add -r/--retain option to keep log files after success make logs file append-only remove -g/-G/-l logging options sugggest tailing appropriate log file on failure enhance -v/--verbose behavior
This commit is contained in:
@ -77,18 +77,19 @@ pg_log(eLogType type, char *fmt,...)
|
||||
vsnprintf(message, sizeof(message), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (log_opts.fd != NULL)
|
||||
/* PG_VERBOSE is only output in verbose mode */
|
||||
if (type != PG_VERBOSE || log_opts.verbose)
|
||||
{
|
||||
fwrite(message, strlen(message), 1, log_opts.fd);
|
||||
fwrite(message, strlen(message), 1, log_opts.internal);
|
||||
/* if we are using OVERWRITE_MESSAGE, add newline */
|
||||
if (strchr(message, '\r') != NULL)
|
||||
fwrite("\n", 1, 1, log_opts.fd);
|
||||
fflush(log_opts.fd);
|
||||
fwrite("\n", 1, 1, log_opts.internal);
|
||||
fflush(log_opts.internal);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case PG_INFO:
|
||||
case PG_VERBOSE:
|
||||
if (log_opts.verbose)
|
||||
printf("%s", _(message));
|
||||
break;
|
||||
@ -104,11 +105,6 @@ pg_log(eLogType type, char *fmt,...)
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
case PG_DEBUG:
|
||||
if (log_opts.debug)
|
||||
fprintf(log_opts.debug_fd, "%s\n", _(message));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user