Re: Logging SQL queries?

From: Kevin Brannen <kevinb(at)nurseamerica(dot)net>
To: Stephane Bortzmeyer <bortzmeyer(at)nic(dot)fr>
Cc: PostgreSQL General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Logging SQL queries?
Date: 2002-07-18 19:42:32
Message-ID: 3D371A28.30701@nurseamerica.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-07-18 20:12:49 PostgreSQL vs. SapDB slashdot discussion
Previous Message Siva Kumar 2002-07-18 19:09:01 Too many clients to Postgresql server