Re: timestams in the the pg_standby output - Mailing list pgsql-general

From Greg Smith
Subject Re: timestams in the the pg_standby output
Date
Msg-id 4B42D898.6090805@2ndquadrant.com
Whole thread Raw
In response to timestams in the the pg_standby output  (Tim Uckun <timuckun@gmail.com>)
Responses Re: timestams in the the pg_standby output  (Tim Uckun <timuckun@gmail.com>)
List 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@2ndQuadrant.com  www.2ndQuadrant.com

pgsql-general by date:

Previous
From: "Dann Corbit"
Date:
Subject: Re: PostgreSQL Write Performance
Next
From: Tim Uckun
Date:
Subject: Re: timestams in the the pg_standby output