Re: Logging which local address was connected to in log_line_prefix

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Greg Sabino Mullane <htamfids@gmail.com>, Jim Jones <jim.jones@uni-muenster.de>, david@pgmasters.net, Peter Eisentraut <peter@eisentraut.org>, Cary Huang <cary.huang@highgo.ca>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2025-04-06T22:41:18Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add local-address escape "%L" to log_line_prefix.

On Sun, Apr 06, 2025 at 06:01:01PM -0400, Tom Lane wrote:
> I don't really care for #3 or #4, but I'm ambivalent between #1 and
> #2.  I think the worry about confusion originated when the patch
> would print "[local]" for either a Unix socket or a background
> process, and that certainly was confusing.  "[local]" versus
> an empty string is not so ambiguous, so maybe it's fine.

I'd suggest the addition of this data to csvlog.c and jsonlog.c,
perhaps only adding this information if local_host[0] is not '\0'
rather than assigning a default "[none]" all the time to save some
space in the entries generated.

config.sgml would also need a refresh:
- runtime-config-logging-jsonlog-keys-values for the new key/value
pair.
- runtime-config-logging-csvlog for the CREATE TABLE and the list of
columns.

Perhaps it would be time to switch the list of columns to use a proper
table instead of a raw list for the CSV docs, for clarity.
--
Michael