Re: timestams in the the pg_standby output

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Tim Uckun <timuckun(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: timestams in the the pg_standby output
Date: 2010-01-05 06:13:44
Message-ID: 4B42D898.6090805@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tim Uckun wrote:
> Is there a way to get pg_standby to put timestamps in the output it
> generates? I am currently piping the output to a log fie but since it
> contains no timestamps it's of limited use to me.
>

Nope; already on my TODO list to take care of one day since it annoys me
too. What you can do is run another program in parallel that does
something similar to the "tail -f" behavior, letting you watch new files
added to the log file. As each line is read, timestamps it and print
the line. There's a sample that's almost what you want at
http://stackoverflow.com/questions/441437/how-do-i-implement-tail-f-with-timeout-on-read-in-perl
; basically you'd just need to replace

| print "$item";
print "\n" if ($line_no % DOTS_PER_LINE == 0);
printf "%s\n", strftime("%Y-%m-%d %H:%M:%S", localtime(time))
if ($line_no % (DOTS_PER_LINE * LINES_PER_BREAK) == 0);
|
|With something like this:|
||||
||| printf "%s %s\n", strftime("%Y-%m-%d %H:%M:%S", localtime(time)),
$item|
||
|(untested, and I am not a regular Perl programmer, its but File::Tail
is the best library I know of to do this sort of thing)|
||||
||

--
Greg Smith 2ndQuadrant Baltimore, MD
PostgreSQL Training, Services and Support
greg(at)2ndQuadrant(dot)com www.2ndQuadrant.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim Uckun 2010-01-05 07:22:48 Re: timestams in the the pg_standby output
Previous Message Dann Corbit 2010-01-05 06:03:39 Re: PostgreSQL Write Performance