mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Improve frontend error logging style.
Get rid of the separate "FATAL" log level, as it was applied so inconsistently as to be meaningless. This mostly involves s/pg_log_fatal/pg_log_error/g. Create a macro pg_fatal() to handle the common use-case of pg_log_error() immediately followed by exit(1). Various modules had already invented either this or equivalent macros; standardize on pg_fatal() and apply it where possible. Invent the ability to add "detail" and "hint" messages to a frontend message, much as we have long had in the backend. Except where rewording was needed to convert existing coding to detail/hint style, I have (mostly) resisted the temptation to change existing message wording. Patch by me. Design and patch reviewed at various stages by Robert Haas, Kyotaro Horiguchi, Peter Eisentraut and Daniel Gustafsson. Discussion: https://postgr.es/m/1363732.1636496441@sss.pgh.pa.us
This commit is contained in:
@ -100,7 +100,8 @@ main(int argc, char *argv[])
|
||||
maintenance_db = pg_strdup(optarg);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||
/* getopt_long already emitted a complaint */
|
||||
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -109,7 +110,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
case 0:
|
||||
pg_log_error("missing required argument database name");
|
||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
|
||||
exit(1);
|
||||
case 1:
|
||||
dbname = argv[optind];
|
||||
@ -117,7 +118,7 @@ main(int argc, char *argv[])
|
||||
default:
|
||||
pg_log_error("too many command-line arguments (first is \"%s\")",
|
||||
argv[optind + 1]);
|
||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user