Re: PATCH: numeric timestamp in log_line_prefix - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: PATCH: numeric timestamp in log_line_prefix
Date
Msg-id 20150907192719.GS2912@alvherre.pgsql
Whole thread Raw
In response to Re: PATCH: numeric timestamp in log_line_prefix  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: PATCH: numeric timestamp in log_line_prefix
List pgsql-hackers
> +            case 'n':
> +                {
> +                    struct    timeval tv;
> +                    char    strfbuf[128];
> +
> +                    gettimeofday(&tv, NULL);
> +                    sprintf(strfbuf, "%ld.%03d", tv.tv_sec, (int)(tv.tv_usec / 1000));
> +
> +                    if (padding != 0)
> +                        appendStringInfo(buf, "%*s", padding, strfbuf);
> +                    else
> +                        appendStringInfoString(buf, strfbuf);
> +                }
> +                break;

I wonder about this separate gettimeofday() call.  We already have
formatted_log_time which is used for CSV logs and freeform log lines
(stderr/syslog); if we introduce a separate gettimeofday() call here,
and the user has %n in freeform log and CSV logging is active, the
timings will diverge occasionally.

Maybe I'm worrying over nothing, because really what use case is there
for having the two log formats enabled at the same time?  Yet somebody
went some lengths to ensure they are consistent; I think we should do
likewise here.

I'm happy to be outvoted on this, so consider this a -0.5 for this
particular implementation.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: creating extension including dependencies
Next
From: Petr Jelinek
Date:
Subject: Re: creating extension including dependencies