Re: Log prefix missing for subscriber log messages received from publisher - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Log prefix missing for subscriber log messages received from publisher
Date
Msg-id 33f8b25d-1ea4-4377-ab8c-c29a9eb02122@oss.nttdata.com
Whole thread Raw
In response to Re: Log prefix missing for subscriber log messages received from publisher  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: Log prefix missing for subscriber log messages received from publisher
List 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




pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: small fix for pg_overexplain docs
Next
From: "David G. Johnston"
Date:
Subject: Re: PostgreSQL 16 bug feedback