Re: Logging SQL queries? - Mailing list pgsql-general

From Kevin Brannen
Subject Re: Logging SQL queries?
Date
Msg-id 3D371A28.30701@nurseamerica.net
Whole thread Raw
In response to Logging SQL queries?  (Steve Lane <slane@fmpro.com>)
Responses Re: Logging SQL queries?  (Ralph Graulich <maillist@shauny.de>)
Re: Logging SQL queries?  (Stephane Bortzmeyer <bortzmeyer@nic.fr>)
List pgsql-general
Stephane Bortzmeyer wrote:
...
> I cannot write this function in Python (because it exists only as a
> safe language), I can do it in Perl but Perl in PostgreSQL does not
> have global variables so I have to openlog() each time (I'm afraid,
> although I didn't benchmark, that it may slow down the
> system.). Before I study C or Tcl, does anyone has a working solution?

You can easily do it Perl, (I do :-) use the Unix::Syslog module.  Just
call openlog() once at the beginning and off you go, able to call
syslog() anywhere you need to.

Ignoring the argument about whether global vars are good or bad, global
vars in Perl are merely fully [package] qualified named vars.
Therefore, you can do:

$main::mylog = "some value";

and if you always reference it that way, e.g.
    print "Log file is $main::mylog\n"
you can use it anywhere in your program; that is in any file and in any
function (truly global).

HTH,
Kevin


pgsql-general by date:

Previous
From: "Gregory Wood"
Date:
Subject: 7.3 support for IN
Next
From: Bruce Momjian
Date:
Subject: PostgreSQL vs. SapDB slashdot discussion