Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNpW8-0001go-EG for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Feb 2022 05:21:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nNpW6-0005iy-9b for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Feb 2022 05:21:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNpW4-0005ip-FC for pgsql-hackers@lists.postgresql.org; Sat, 26 Feb 2022 05:21:14 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNpW1-0001vR-Eo for pgsql-hackers@lists.postgresql.org; Sat, 26 Feb 2022 05:21:11 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 56E125C0241; Sat, 26 Feb 2022 00:21:07 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sat, 26 Feb 2022 00:21:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=YS6g6/V6xO8ePYWeCF72OhrKR4r29AzcDFnnIY dlfus=; b=OA/FWTWxJY44mAZgaVykhw/X7CW+qVea8WLK8Hb6cwfC4uxvKoDOrN UIuI8X/AvtkgUZ0kyimvDx+wtVoh9897Mxwgg7+P4G9052PQ0neTDLNjbSoCslDG ppbXCP9GdnqdI3q0ARDhWkmMDgrBEa5+ChBADA+2cT87UImEynoMf8hh3RTGhC9b OwuAGSUqmn00VRvbUK2+9lzsnhB31sEuhPprjJfhXsE6BZkQc5IGSMaz/hOILFR4 E74MiBKwrf0gLVZPVA4sh9yJPGsAxybdsaRr1bLU7SIUdcngV0v3kls0SyHLwAas kk6OpsARdm78i78bmu52Rs/jyD6KS8hg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=YS6g6/V6xO8ePYWeC F72OhrKR4r29AzcDFnnIYdlfus=; b=ew+mEIp5OWi0J3AadiWC4lquDoPnoIzkK 7RPs4jgEZF60BifKVAxgrCataMwGcGbH7WM+q20sALxWoRELsdnpcryGBvqlOMqM SrBeHYbdKBAYOVHiNoHeq5PGVPxJwQCKpkiwnPZt1OkjfbzJ+vYMjwAT/fcofx9g jTyflIl3lUX3fwyv/iRJ0Lf2v3b6tYf6lljVjjewLKSLIjelLnfh+wSj37zzaXAp lZLxyDtr1wF28Qo5DMIZPgKZv1s2IZAQhx6i1zuqOlX73Qh0U57ye886DIiUR91d 6VybWIiSnRZ83jGMp+QIf7fTBzphVbpgUnPlrVE8id0RRhyNbEr2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrleehgdejlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepvdegudeuhfdtueeltedtveejheeh ieevueeigeelteegleejleeiueeiheegvefhnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 26 Feb 2022 00:21:05 -0500 (EST) Date: Sat, 26 Feb 2022 14:21:01 +0900 From: Michael Paquier To: Tom Lane Cc: Peter Eisentraut , Robert Haas , PostgreSQL Hackers Subject: Re: Frontend error logging style Message-ID: References: <632f02ed-12ac-b91f-0e99-9c1b086f8cd0@enterprisedb.com> <913687.1645572199@sss.pgh.pa.us> <6fdb3ab3-f093-27b9-dfdc-c391e69163fc@enterprisedb.com> <1346360.1645715441@sss.pgh.pa.us> <1895619.1645809325@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="UW9e6asxQmvxXgYU" Content-Disposition: inline In-Reply-To: <1895619.1645809325@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --UW9e6asxQmvxXgYU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --UW9e6asxQmvxXgYU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmIZuL0ACgkQnvQgOdby QH0V9Q//a1zJnP0/et8B/gedsGGBsXUdyMe/eeXB1Wg+I6LbPf/ixGgYfirDAJcG AhzeBWxzyXSSPmKjBYQ8n2Y7lLQmLVzK9KAwt3PnNsU0zvPuT5iEUZh8dMdcUjkL aeLE9qbWF1Ozk0lI1ZshA2dYuahJ5YnkrJMQSqsIdtmDUAqyaMiGYQDZrFryq1vb MYfP8UaYIXg0EaG3vIm9bxUnuTG9fonluzH+J3+//AOXd3jLmdKhkX3SAAuRRxpM oWJ+H/g2Ce0h/jo3ZhxuFNPLb8O4Xw33Ldro3u4nStkA902W+AxXJBVxWe2jQ6Ax RJOX1ff7oNxvLYx6/9zhw2S5DlbB9TBCCw4tZ6SMmp2lI2dvX7e+plStK0YmyR4G REgZnEICuww81xJpuhpv9fNcaq76pR2aNf3FXSt56qqz5JogZl1yUmA5uyGjbz7l f4FIxpKrpT2au80ZgsbFqOE9Xm4EKGWv9S2KCRQV7ZiLzQSkEy3h5hz8d17Ylo5p 0lehKNmJGhmKi62V3awF1weJ1PVqOBHL7p9RLf/TSiVDPpLb8TghoyVqP1X12TtD WfMk2Ah2ACTs/c+14MwPdFjFVBIuY1XQVF6wNmgTS5RziqIgS8SPH0u9snB4Comw 011lLZ5WzskzcqoFnmunaflL3sIVCydkTLwSAf+qPky/MCFpjmM= =Wq0I -----END PGP SIGNATURE----- --UW9e6asxQmvxXgYU--