pgsql: Refactor fallback to stderr for csvlog to handle better WIN32 se - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Refactor fallback to stderr for csvlog to handle better WIN32 se
Date
Msg-id E1mYfMq-0000aV-JJ@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Refactor fallback to stderr for csvlog to handle better WIN32 service case

send_message_to_server_log() would force a redirection of a log entry to
stderr in some cases for csvlog, like the syslogger not being available
yet.  If this happens, csvlog would fall back to stderr to log
some information rather than nothing.  The code was organized so as
stderr is done before csvlog, with csvlog checking that stderr did not
happen yet with a reversed condition.  With this code organization, it
could be possible to lose some messages if running Postgres as a service
on WIN32, as there is no usable stderr, and the handling of the
StringInfoData holding the message for stderr was rather confusing
because of that.

This commit moves the csvlog handling to be before stderr, as as we are
able to track down if it is necessary to log something to stderr.  The
reduces the handling of stderr to be in a single code path, adding a
fallback to event logs for a WIN32 service.  This also simplifies the
way we handle the StringInfoData for stderr, making easier the
integration of new file-based log destinations.  I got to play with
services and event logs on Windows while checking this change.

Reviewed-by: Chris Bandy
Discussion: https://postgr.es/m/YV0vwBovEKf1WXkl@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8b76f89c37973082b3d64f5a27937efcca9d65f6

Modified Files
--------------
src/backend/utils/error/elog.c | 54 +++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 30 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Doc: update our claims about the minimum recommended AIX version
Next
From: Andrew Dunstan
Date:
Subject: Re: pgsql: Reference test binary using TESTDIR in 001_libpq_pipeline.pl.