Re: Add jsonlog log_destination for JSON server logs

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Sehrope Sarkuni <sehrope@jackdb.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>, david@fetter.org
Date: 2021-11-10T13:44: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. Introduce log_destination=jsonlog

  2. Refactor set of routines specific to elog.c

  3. Fix compilation warning in syslogger.c

  4. Refactor per-destination file rotation in logging collector

  5. Refactor output file handling when forking syslogger under EXEC_BACKEND

  6. Add regression tests for csvlog with the logging collector

  7. Refactor the syslogger pipe protocol to use a bitmask for its options

Attachments

On Tue, Oct 19, 2021 at 08:02:02PM +0900, Michael Paquier wrote:
> 0001 and 0002, the refactoring bits, are in a rather committable
> shape, so I'd like to apply that as the last refactoring pieces I know
> of for this thread.  0003 still needs a closer lookup, and one part I
> do not like much in it is the split for [u]int and long values when it
> comes to key and values.

I have finally come around 0003 and reviewed it.  There were a couple
of issues within it, from complications in the code that did not feel
necessary to incorrect handling of the values logged, mostly around 
when values should be escaped or not.  jsonlog.c has been reorganized
so as its fields match with csvlog.c, and I have simplified the APIs
in charge of saving the integers into a single one with an argument
list and an option to control if the value should be escaped or not.

postgresql.conf.sample also needed a refresh.

I have also spent some time on the documentation, where the list of
JSON keys with their descriptions and types has been changed to a
table, for clarity.  The list was a bit incorrect (incorrect fields
and missing entries), so that should hopefully be clean now.

Patch 0003 has been heavily reworked, and it would be good to have an
extra pair of eyes on it.  So I have switched the CF entry as "Needs
Review" and added my name to the list of authors (originally this
stuff took code portions of own module, as well).
--
Michael