Re: backend type in log_line_prefix?

Peter Eisentraut <peter.eisentraut@2ndquadrant.com>

From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-02-21T09:09: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. Add backend type to csvlog and optionally log_line_prefix

  2. Remove am_syslogger global variable

  3. Unify several ways to tracking backend type

  4. Refactor ps_status.c API

  5. Add background worker type

Attachments

On 2020-02-13 09:56, Peter Eisentraut wrote:
> Attached is a demo patch that adds a placeholder %b for log_line_prefix
> (not in the default setting) that contains the backend type, the same
> that you see in pg_stat_activity and in the ps status.  I would have
> found this occasionally useful when analyzing logs, especially if you
> have a lot of background workers active.  Thoughts?

After positive initial feedback, here is a more ambitious patch set.  In 
particular, I wanted to avoid having to specify the backend type (at 
least) twice, once for the ps display and once for this new facility.

I have added a new global variable MyBackendType that uses the existing 
BackendType enum that was previously only used by the stats collector. 
Then the ps display, the stats collector, the log_line_prefix, and other 
places can just refer to this to know "who am I".  (There are more 
places like that, for example in the autovacuum system, so patch 0004 in 
particular could be expanded in analogous ways.)

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services