1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +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:
Bruce Momjian
2012-03-12 19:47:54 -04:00
parent b4af1c25bb
commit 717f6d6085
16 changed files with 257 additions and 234 deletions

View File

@ -13,7 +13,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
static void check_data_dir(const char *pg_data);
static void check_bin_dir(ClusterInfo *cluster);
@ -34,24 +34,37 @@ static int win32_check_directory_write_permissions(void);
* instead of returning should an error occur.
*/
int
exec_prog(bool throw_error, const char *fmt,...)
exec_prog(bool throw_error, bool is_priv,
const char *log_file, const char *fmt,...)
{
va_list args;
int result;
char cmd[MAXPGPATH];
mode_t old_umask;
if (is_priv)
old_umask = umask(S_IRWXG | S_IRWXO);
va_start(args, fmt);
vsnprintf(cmd, MAXPGPATH, fmt, args);
va_end(args);
pg_log(PG_INFO, "%s\n", cmd);
pg_log(PG_VERBOSE, "%s\n", cmd);
result = system(cmd);
if (is_priv)
umask(old_umask);
if (result != 0)
{
pg_log(throw_error ? PG_FATAL : PG_INFO,
"There were problems executing \"%s\"\n", cmd);
report_status(PG_REPORT, "*failure*");
fflush(stdout);
pg_log(PG_VERBOSE, "There were problems executing \"%s\"\n", cmd);
pg_log(throw_error ? PG_FATAL : PG_REPORT,
"Consult the last few lines of \"%s\" for\n"
"the probable cause of the failure.\n",
log_file);
return 1;
}