Re: backend type in log_line_prefix?

Justin Pryzby <pryzby@telsasoft.com>

From: Justin Pryzby <pryzby@telsasoft.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Date: 2020-03-14T15:49:49Z
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

On Fri, Feb 21, 2020 at 10:09:38AM +0100, Peter Eisentraut wrote:
> From 75ac8ed0c47801712eb2aa300d9cb29767d2e121 Mon Sep 17 00:00:00 2001
> From: Peter Eisentraut <peter@eisentraut.org>
> Date: Thu, 20 Feb 2020 18:16:39 +0100
> Subject: [PATCH v2 3/4] Add backend type to csvlog and optionally log_line_prefix

> diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
> index c1128f89ec..206778b1c3 100644
> --- a/doc/src/sgml/config.sgml
> +++ b/doc/src/sgml/config.sgml
> @@ -6470,6 +6470,11 @@ <title>What to Log</title>

          characters are copied straight to the log line. Some escapes are
          only recognized by session processes, and will be treated as empty by
          background processes such as the main server process. Status
...
              <entry>Escape</entry>
              <entry>Effect</entry>
              <entry>Session only</entry>

>               <entry>Application name</entry>
>               <entry>yes</entry>
>              </row>
> +            <row>
> +             <entry><literal>%b</literal></entry>
> +             <entry>Backend process type</entry>
> +             <entry>yes</entry>

=> should say "no", it's not blank for background processes:

> +
> +					if (MyProcPid == PostmasterPid)
> +						backend_type_str = "postmaster";
> +					else if (MyBackendType == B_BG_WORKER)
> +						backend_type_str = MyBgworkerEntry->bgw_type;
> +					else
> +						backend_type_str = pgstat_get_backend_desc(MyBackendType);

-- 
Justin