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

From Álvaro Herrera
Subject Re: Log prefix missing for subscriber log messages received from publisher
Date
Msg-id 202507171615.3uafckrnbssa@alvherre.pgsql
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-Jul-18, Fujii Masao wrote:

> 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?

I like the idea of reducing duplication.  I don't like the "prefix"
as proposed though, because it's not going to work well for translation
(string building) -- I'd rather pass the entire phrase from caller, so
that the translator has one piece to translate which lives in the module
that emits it.  I think I'd do something like

    ereport(LOG,
            errmsg_internal("%s: %.*s",
                        _(prefix), len, message));

and see to it that each caller uses gettext_noop() around the string
they pass as "arg", for gettext to collect.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Non-text mode for pg_dumpall
Next
From: Laurenz Albe
Date:
Subject: Re: PostgreSQL 16 bug feedback