capturing and storing query statement with rules

Andrew Gould <andrewgould@yahoo.com>

From: Andrew Gould <andrewgould@yahoo.com>
To: Postgres Mailing List <pgsql-general@postgresql.org>
Date: 2003-06-24T20:17:39Z
Lists: pgsql-hackers, pgsql-general
I would like to create a audit log of update and
delete queries against a table.  I want the log on the
server side, since access will be done using various
clients via ODBC.  I would like to capture the user,
current datetime and the query statement.  My thought
was to accomplish this by creating a rule that will
insert the information into a log table.

How can I captures the query statement so that I can
place it in a insert query?  Is there a variable in
the server that holds the query statement as a string?

Am I about to go in over my head (again)?

Thanks,

Andrew