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 1mmhL9-0007FJ-AI for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Nov 2021 19:08:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mmhL8-0004Cr-9G for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Nov 2021 19:08:26 +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 1mmhL7-0004Ci-Vp for pgsql-hackers@lists.postgresql.org; Mon, 15 Nov 2021 19:08:25 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmhL4-000586-KK for pgsql-hackers@lists.postgresql.org; Mon, 15 Nov 2021 19:08:24 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id ED9585C0259; Mon, 15 Nov 2021 14:08:21 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 15 Nov 2021 14:08:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=Zn3DtVUOOHdurB4sAj5rPa6rGHiz+ki5gWMTXVZVo Us=; b=O9nzKWFQyHaBh/SB5Pq6kIAh/kUf61Yy/2m96/fXp7Zi6Cg0/8D+h2MeP ybtrBoRLQDnpc2Qyq6XByyOZ/YwkB3Sp+3fRs8jJER7ulWDO4kpESqYMXQtAvsk0 3kD8gXq19bISDpA5uwIwOOnfhpaj3RHrb32KAYGONZg08H9D9DBHHWifFDsM5hZV hwkDFL661QSzlbv/3yc6UsfI73BC2xLTc+/XIPLmT6q0GteLbzgrcsSW6UgeOTsb b6a0klUV0a/HhC1FYep1PGt/RGMhfOpk5y6kTnAAZxlM5jNrGT+xrQzzc9As/ptO NWdFP+sYlnKxP6CQTiFqFSz3i5n8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfedtgdelgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthejre dttdefjeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdr vghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusgdrtghomheqnecuggftrfgrth htvghrnhepfeejgeehteeuhfevveduleeufedtjeetiefftedvudfhtdeifefgueettdev gefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepph gvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Nov 2021 14:08:20 -0500 (EST) Message-ID: Date: Mon, 15 Nov 2021 20:08:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: Frontend error logging style Content-Language: en-US To: Tom Lane , pgsql-hackers@lists.postgresql.org References: <1363732.1636496441@sss.pgh.pa.us> From: Peter Eisentraut In-Reply-To: <1363732.1636496441@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 09.11.21 23:20, Tom Lane wrote: > 2. What is the preferred style for adding extra lines to log messages? > I see a lot of direct prints to stderr: > > pg_log_error("missing required argument: database name"); > fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); > exit(1); This is mainly used for those few messages that are sort of a "global standard". > but a number of places have chosen to do this: > > pg_log_error("query failed: %s", PQerrorMessage(conn)); > pg_log_error("query was: %s", todo); > > and some places got creative and did this: > > pg_log_error("query failed: %s", PQerrorMessage(conn)); > pg_log_info("query was: %s", sql.data); I can't decide between those two. It depends on how each program handles the log level internally. Some kind of "detail" system could be useful. But it would need to be tied into the log level, layout, etc. I have not seen much inspiration for this kind of thing in other logging libraries, so I didn't do anything about it yet.