On Fri, Feb 25, 2022 at 12:15:25PM -0500, Tom Lane wrote: > I feel that the reasonable alternatives are either to drop the FATAL > log level, or try to make it actually mean something by consistently > using it for errors that are indeed fatal. I had a go at doing the > latter, but eventually concluded that that way madness lies. It's > not too hard to use "pg_log_fatal" when there's an exit(1) right > after it, but there are quite a lot of cases where a subroutine > reports an error and returns a failure code to its caller, whereupon > the caller exits. Either the subroutine has to make an unwarranted > assumption about what its callers will do, or we need to make an API > change to allow the subroutine itself to exit(), or we are going to > present a user experience that is inconsistently different depending > on internal implementation details.
Nice code cut. > I conclude that we ought to drop the separate FATAL level and just > use ERROR instead. FWIW, I have found the uses of pg_log_error() and pg_log_fatal() rather confusing in some of the src/bin/ tools, so I am in favor of removing completely one or the other, and getting rid of FATAL is the best choice. > The attached revision does that, standardizes on pg_fatal() as the > abbreviation for pg_log_error() + exit(1), and invents detail/hint > features as per previous discussion. +#define pg_log_warning_hint(...) do { \ + if (likely(__pg_log_level <= PG_LOG_WARNING)) \ + pg_log_generic(PG_LOG_WARNING, PG_LOG_HINT, __VA_ARGS__); \ } while(0) Hm. I am not sure to like much this abstraction by having so many macros that understand the log level through their name. Wouldn't it be cleaner to have only one pg_log_hint() and one pg_log_detail() with the log level passed as argument of the macro? -- Michael
signature.asc
Description: PGP signature