Re: Reducing the log spam

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Jim Jones <jim.jones@uni-muenster.de>, Laurenz Albe <laurenz.albe@cybertec.at>, Jelte Fennema-Nio <postgres@jeltef.nl>, Isaac Morland <isaac.morland@gmail.com>, Justin Pryzby <pryzby@telsasoft.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-04-02T19:23:38Z
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. plpgsql: make WHEN OTHERS distinct from WHEN SQLSTATE '00000'.

Fujii Masao <masao.fujii@oss.nttdata.com> writes:
> Filtering log messages by SQLSTATE might be useful for some users,
> but I'm unsure if it should belong in the core. There are also other
> potential filtering needs, such as by application name, client host,
> database, or roles. Adding only SQLSTATE filtering may not be good idea,
> while supporting all possible cases in the core wouldn't be practical either.

> Given that, I think implementing this as an extension using emit_log_hook
> would be a better approach. Anyway, I'd like to hear more opinions from
> other hackers on this.

I took a brief look and I concur with Fujii-san's conclusion: this'd
be a fine extension a/k/a contrib module, but it seems a bit too
opinionated about what sort of filtering is needed to be appropriate
within elog.c itself.

Also, just as a minor coding thought, I'd suggest using -1 not 0
to terminate the array of encoded SQLSTATEs, rather than assuming
that nobody would write 00000.  Compare commit 58fdca220.

			regards, tom lane