Re: WIP: Separate log file for extension

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Antonin Houska <ah(at)cybertec(dot)at>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: Separate log file for extension
Date: 2017-09-10 07:50:45
Message-ID: CABUevEw4-a-0T8Hka7Z-3WYCY+2-Sh0HY4TX_m=Qqk_xKRH2Cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 25, 2017 at 12:12 AM, Antonin Houska <ah(at)cybertec(dot)at> wrote:

> Attached is a draft patch to allow extension to write log messages to a
> separate file. It introduces a concept of a "log stream". The extension's
> shared library gets its stream assigned by calling this function from
> _PG_init()

> my_stream_id = get_log_stream("my_extension", &my_log_stream);
>

I like this idea in general.

> Then it's supposed to change some of its attributes
>
> adjust_log_stream_attr(&stream->filename, "my_extension.log");
>

This, however, seems to be wrong.

The logfile name does not belong in the extension, it belongs in the
configuration file. I think the extension should set it's "stream id" or
whatever you want to call it, and then it should be possible to control in
postgresql.conf where that log is sent.

Also, what if this extension is loaded on demand in a session and not via
shared_preload_libraries? It looks like the syslogger only gets the list of
configured streams when it starts?

In short, I think the solution should be more generic, and not "just for
extensions".

I completely missed this thread when I did my quick-wip at
https://www.postgresql.org/message-id/flat/CABUevExztL0GORyWM9S4tR_Ft3FmJbRaxQdxj+BQZjpvmRurdw(at)mail(dot)gmail(dot)com#CABUevExztL0GORyWM9S4tR_Ft3FmJbRaxQdxj+BQZjpvmRurdw@mail.gmail.com
-- some of the changes made were close enough that I got the two confused
:) Based on the feedback of that one, have you done any performance checks?

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-09-10 08:30:14 Re: Setting pd_lower in GIN metapage
Previous Message Fabien COELHO 2017-09-10 06:31:38 Re: pgbench more operators & functions