Re: Lost logs with csvlog redirected to stderr under WIN32 service

Chris Bandy <bandy.chris@gmail.com>

From: Chris Bandy <bandy.chris@gmail.com>
To: Michael Paquier <michael@paquier.xyz>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Date: 2021-10-07T02:33:24Z
Lists: pgsql-hackers
On 10/6/21 12:10 AM, Michael Paquier wrote:
> I have thought about various ways to
> fix that, and finished with a solution where we handle csvlog first,
> and fallback to stderr after so as there is only one code path for
> stderr, as of the attached.  This reduces a bit the confusion around
> the handling of the stderr data that gets free()'d in more code paths
> than really needed.

I don't have a windows machine to test, but this refactor looks good to me.

> +	/* Write to CSV log, if enabled */
> +	if ((Log_destination & LOG_DESTINATION_CSVLOG) != 0)

This was originally "if (Log_destination & LOG_DESTINATION_CSVLOG)" and
other conditions nearby still lack the "!= 0". Whatever the preferred
style, the lines touched by this patch should probably do this consistently.

-- Chris



Commits

  1. Refactor fallback to stderr for csvlog to handle better WIN32 service case