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-09-14T06:06:41Z
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 →
-
Introduce log_destination=jsonlog
- dc686681e079 15.0 landed
-
Refactor set of routines specific to elog.c
- ac7c80758a7a 15.0 landed
-
Fix compilation warning in syslogger.c
- 05c4248ad1bf 15.0 landed
-
Refactor per-destination file rotation in logging collector
- 5c6e33f07153 15.0 landed
-
Refactor output file handling when forking syslogger under EXEC_BACKEND
- 5b0b699f748e 15.0 landed
-
Add regression tests for csvlog with the logging collector
- 72b76f76161c 15.0 landed
-
Refactor the syslogger pipe protocol to use a bitmask for its options
- 2d77d835403a 15.0 landed
On Mon, Sep 13, 2021 at 11:56:52PM -0400, Sehrope Sarkuni wrote: > Good catch. Staring at that piece again, that's tricky as it tries to > aggressively free the buffer before calling write_cvslog(...). Which can't > just be duplicated for additional destinations. > > I think we need to pull up the negative case (i.e. syslogger not available) > before the other destinations and if it matches, free and exit early. > Otherwise, free the buffer and call whatever destination routines are > enabled. Yes, I got a similar impression. > I started on a bit of this as well. There's so much overlap already between > the syslog_ and csvlog code that I'm going to put that together first. Then > the json addition should just fall into a couple of call sites. > > I'm thinking of adding an internal struct to house the FILE* and file > names. Then all the opening, closing, and log rotation code can pass > pointers to those and centralize the pfree() and NULL checks. Agreed on both points (using a structure and doing the refactoring as a first patch). -- Michael