Re: Log prefix missing for subscriber log messages received from publisher
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: vignesh C <vignesh21@gmail.com>, Álvaro Herrera <alvherre@kurilemu.de>
Cc: Fujii Masao <masao.fujii@gmail.com>,
pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-17T15:52:31Z
Lists: pgsql-hackers
On 2025/07/17 23:34, Fujii Masao wrote:
>> The attached v5 version patch
>> has the changes for the same.
>
> Thanks for updating the patches!
The current patches add nearly identical notice_receiver functions
in multiple places such as libpqwalreceiver.c and elsewhere. To avoid
duplicating the same logic, could we define a shared notice receiver
function in a common file, like libpq-be-fe-helpers.h, and use it in
all three locations?
--------------------
static inline void
libpqsrv_notice_receiver(void *arg, const PGresult *res)
{
char *message;
int len;
char *prefix = (char *) arg;
/*
* Trim the trailing newline from the message text returned from
* PQresultErrorMessage(), as it always includes one, to produce
* cleaner log output.
*/
message = PQresultErrorMessage(res);
len = strlen(message);
if (len > 0 && message[len - 1] == '\n')
len--;
ereport(LOG,
errmsg("received message %s: %.*s", prefix, len, message));
}
--------------------
Regards,
--
Fujii Masao
NTT DATA Japan Corporation
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove translation marker from libpq-be-fe-helpers.h.
- a7ca73af662b 19 (unreleased) landed
-
Log remote NOTICE, WARNING, and similar messages using ereport().
- 112faf1378ee 19 (unreleased) landed
-
Remove translation markers from libpq-be-fe-helpers.h
- 213c959a294d 17.0 cited