[HACKERS] WIP: Separate log file for extension - Mailing list pgsql-hackers

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);

Then it's supposed to change some of its attributes

    adjust_log_stream_attr(&stream->filename, "my_extension.log");

and to use the stream id in ereport() calls

    ereport(LOG, (errmsg("Hello world"), errstream(my_stream_id)));

The EXEC_BACKEND mechanism makes initialization of the log streams by
postmaster child processes non-trivial. I decided to extend
save_backend_variables() and restore_backend_variables() accordingly. Maybe
someone has better idea.

pgaudit seems to be the most obvious use case for this enhancement, but it
might be useful for many other extensions.

--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] Draft release notes up for review
Next
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] ECPG: WHENEVER statement with DO CONTINUE action