Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Alvaro Herrera
Jeff Davis wrote: > On Mon, 2015-09-07 at 18:28 -0300, Alvaro Herrera wrote: > > I think the extra ugliness is warranted, since it's not THAT much > > additional ugliness, and not doing it could be considered a regression; > > apparently strftime can be slower even than snprintf, so doing it

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Jeff Davis
On Mon, 2015-09-07 at 18:28 -0300, Alvaro Herrera wrote: > I noticed %t, but I don't think we care since the precision is so poor. > Making m and n work in unison seems enough. I think it would be > reasonably simple to handle %t in the same way, but I'm not sure we > care. OK. > I think the

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Alvaro Herrera
Jeff Davis wrote: > On Sun, 2015-03-22 at 19:47 +0100, Andres Freund wrote: > > On 2015-03-22 00:47:12 +0100, Tomas Vondra wrote: > > > from time to time I need to correlate PostgreSQL logs to other logs, > > > containing numeric timestamps - a prime example of that is pgbench. With > > > %t and

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Jeff Davis
On Mon, 2015-09-07 at 17:47 -0300, Alvaro Herrera wrote: > Jeff Davis wrote: > > On Sun, 2015-03-22 at 19:47 +0100, Andres Freund wrote: > > > On 2015-03-22 00:47:12 +0100, Tomas Vondra wrote: > > > > from time to time I need to correlate PostgreSQL logs to other logs, > > > > containing numeric

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Jeff Davis
> 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

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Alvaro Herrera
Jeff Davis wrote: > > 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

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Jeff Davis
On Sun, 2015-03-22 at 19:47 +0100, Andres Freund wrote: > On 2015-03-22 00:47:12 +0100, Tomas Vondra wrote: > > from time to time I need to correlate PostgreSQL logs to other logs, > > containing numeric timestamps - a prime example of that is pgbench. With > > %t and %m that's not quite trivial,

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-09-07 Thread Alvaro Herrera
> + case 'n': > + { > + struct timeval tv; > + charstrfbuf[128]; > + > + gettimeofday(, NULL); > +

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-08-23 Thread Fabien COELHO
1) fix the docs (explicitly say that it's a Unix epoch) I would add the word numeric in front of timestamp both in the doc and in the postgresql.conf.sample, as it justifies the chosen %n. I think we're already using 'unix epoch' in the docs without explicitly stating that it's a numeric

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-08-23 Thread Tomas Vondra
On 08/23/2015 09:28 AM, Fabien COELHO wrote: 1) fix the docs (explicitly say that it's a Unix epoch) I would add the word numeric in front of timestamp both in the doc and in the postgresql.conf.sample, as it justifies the chosen %n. I think we're already using 'unix epoch' in the docs

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-08-22 Thread Fabien COELHO
Hello Tomas, from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because of timezones etc. I propose adding two new log_line_prefix escape sequences - %T and %M, doing

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-08-22 Thread Fabien COELHO
Hello Tomas, Review of v2: attached is a v2 of the patch, reworked based on the comments. The patch applies cleanly to head, it compiles, I tested it and it mostly work as expected, see below. 1) fix the docs (explicitly say that it's a Unix epoch) I would add the word numeric in

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-08-22 Thread Tomas Vondra
Hi all, attached is a v2 of the patch, reworked based on the comments. 1) fix the docs (explicitly say that it's a Unix epoch) 2) handle 'padding' properly 3) get rid of timestamp_str - use appendString* methods directly 4) support just the with milliseconds using '%n' escape sequence All

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-08-22 Thread Tomas Vondra
On 08/22/2015 09:54 PM, Fabien COELHO wrote: Hello Tomas, Review of v2: attached is a v2 of the patch, reworked based on the comments. The patch applies cleanly to head, it compiles, I tested it and it mostly work as expected, see below. 1) fix the docs (explicitly say that it's a Unix

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-08-22 Thread Tomas Vondra
Hi, On 08/22/2015 08:39 AM, Fabien COELHO wrote: Hello Tomas, from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because of timezones etc. I propose adding two new

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-23 Thread Fabien COELHO
The proposed format is much simpler to manage in a script, and if you're interested in runtime, its formatting would be less expensive than %t and %m. Maybe, but do we really need two? How about just %M? I guess Tomas put 2 formats because there was 2 time formats to begin with, but

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-23 Thread Jim Nasby
On 3/22/15 2:59 PM, Tomas Vondra wrote: On 22.3.2015 20:25, Fabien COELHO wrote: The proposed format is much simpler to manage in a script, and if you're interested in runtime, its formatting would be less expensive than %t and %m. Maybe, but do we really need two? How about just %M? I

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-23 Thread Tomas Vondra
On 23.3.2015 23:02, Jim Nasby wrote: On 3/22/15 2:59 PM, Tomas Vondra wrote: On 22.3.2015 20:25, Fabien COELHO wrote: I guess Tomas put 2 formats because there was 2 time formats to begin with, but truncating/rouding if someone really wants seconds is quite easy. Yes, that's why I added

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread David Rowley
On 22 March 2015 at 12:47, Tomas Vondra tomas.von...@2ndquadrant.com wrote: I propose adding two new log_line_prefix escape sequences - %T and %M, doing the same thing as %t and %m, but formatting the value as a number. Hi Tomas, I just had a quick glance at this. Is there a reason you

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Fabien COELHO
About the feature: I find it is a good thing. It may help scripting over the logs, for instance to compute delays between events, whereas the full date-time-tz syntax is maybe nice but heavier to work with afterwards. In addition to the comments already made (typo in doc, padding...): +

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Tom Lane
Fabien COELHO coe...@cri.ensmp.fr writes: On 2015-03-22 00:47:12 +0100, Tomas Vondra wrote: from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because of timezones

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Tomas Vondra
On 22.3.2015 20:25, Fabien COELHO wrote: The proposed format is much simpler to manage in a script, and if you're interested in runtime, its formatting would be less expensive than %t and %m. Maybe, but do we really need two? How about just %M? I guess Tomas put 2 formats because there

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Tomas Vondra
On 22.3.2015 16:58, Fabien COELHO wrote: About the feature: I find it is a good thing. It may help scripting over the logs, for instance to compute delays between events, whereas the full date-time-tz syntax is maybe nice but heavier to work with afterwards. In addition to the comments

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Andres Freund
On 2015-03-22 00:47:12 +0100, Tomas Vondra wrote: from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because of timezones etc. I have a hard time seing this is

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Fabien COELHO
I'm not sure that the . in %.03d is useful. ISTM that it is used for floatting point formatting, but is not needed with integers. It is needed for integers, because you need to make sure 1 millisecond is formatted as .001 and not .1. ISTM that the 03 does that on its own: sh printf %03d\n

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Tomas Vondra
On 22.3.2015 19:45, Fabien COELHO wrote: I'm not sure that the . in %.03d is useful. ISTM that it is used for floatting point formatting, but is not needed with integers. It is needed for integers, because you need to make sure 1 millisecond is formatted as .001 and not .1. ISTM that the

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-22 Thread Jeff Janes
On Sat, Mar 21, 2015 at 4:47 PM, Tomas Vondra tomas.von...@2ndquadrant.com wrote: Hi, from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because of timezones etc.

[HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-21 Thread Tomas Vondra
Hi, from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because of timezones etc. I propose adding two new log_line_prefix escape sequences - %T and %M, doing the same

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-21 Thread Tomas Vondra
On 22.3.2015 02:35, Bruce Momjian wrote: On Sun, Mar 22, 2015 at 12:47:12AM +0100, Tomas Vondra wrote: Hi, from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-21 Thread Bruce Momjian
On Sun, Mar 22, 2015 at 02:41:44AM +0100, Tomas Vondra wrote: Uh, I think you mean number here: entryTime stamp without milliseconds (as a numer)/entry - Oh, right, that's a stupid typo. Also, what number do you

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-21 Thread Alvaro Herrera
Bruce Momjian wrote: On Sun, Mar 22, 2015 at 02:41:44AM +0100, Tomas Vondra wrote: Uh, I think you mean number here: entryTime stamp without milliseconds (as a numer)/entry - Oh, right, that's a stupid typo.

Re: [HACKERS] PATCH: numeric timestamp in log_line_prefix

2015-03-21 Thread Bruce Momjian
On Sun, Mar 22, 2015 at 12:47:12AM +0100, Tomas Vondra wrote: Hi, from time to time I need to correlate PostgreSQL logs to other logs, containing numeric timestamps - a prime example of that is pgbench. With %t and %m that's not quite trivial, because of timezones etc. I propose adding