Re: Proposal: More structured logging

From: Ronan Dunklau <ronan(dot)dunklau(at)aiven(dot)io>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Proposal: More structured logging
Date: 2021-08-23 06:58:50
Message-ID: 3358218.yRJqF8fxcQ@aivenronan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le vendredi 20 août 2021, 11:31:21 CEST Ronan Dunklau a écrit :
> Le jeudi 19 août 2021, 15:04:30 CEST Alvaro Herrera a écrit :
> > On 2021-Aug-13, Ronan Dunklau wrote:
> > > ereport(NOTICE,
> > >
> > > (errmsg("My log message")),
> > > (errtag("EMITTER", "MYEXTENSION")),
> > > (errtag("MSG-ID", "%d", error_message_id))
> > >
> > > );
> >
> > Interesting idea. I agree this would be useful.
> >
> > > Please find attached a very small POC patch to better demonstrate what I
> > > propose.
> >
> > Seems like a good start. I think a further step towards a committable
> > patch would include a test module that uses the new tagging
> > functionality.
>
> Please find attached the original patch + a new one adding a test module.
> The test module exposes a function for generating logs with tags, and a log
> hook which format the tags in the DETAIL field for easy regression testing.
>
> Next step would be to emit those tags in the CSV logs. I'm not sure what
> representation they should have though: a nested csv in it's own column ? A
> key => value pairs list similar to hstore ? A json object ?

I opted for a JSON representation in the CSV logs, please find attached v3
which is the same thing as v2 with another patch for CSV log output.

>
> Also we should probably make this available to the client too, but once
> again the format of the tag field needs to be defined. Any opinion ?

--
Ronan Dunklau

Attachment Content-Type Size
v3-0001-Add-ErrorTag-support.patch text/x-patch 4.0 KB
v3-0002-Add-test-module-for-the-new-tag-functionality.patch text/x-patch 6.6 KB
v3-0003-Output-error-tags-in-CSV-logs.patch text/x-patch 2.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2021-08-23 07:09:04 Re: pg_veryfybackup can fail with a valid backup for TLI > 1
Previous Message Julien Rouhaud 2021-08-23 06:53:34 Re: Mark all GUC variable as PGDLLIMPORT