Re: Logging SQL queries?
От | Stephane Bortzmeyer |
---|---|
Тема | Re: Logging SQL queries? |
Дата | |
Msg-id | 20020719082110.GA19055@nic.fr обсуждение исходный текст |
Ответ на | Re: Logging SQL queries? (Kevin Brannen <kevinb@nurseamerica.net>) |
Список | pgsql-general |
On Thu, Jul 18, 2002 at 02:42:32PM -0500, Kevin Brannen <kevinb@nurseamerica.net> wrote a message of 25 lines which said: > You can easily do it Perl, (I do :-) use the Unix::Syslog module. OK, that's what I do, except that I use Sys::Syslog (Unix::Syslog does not seem to work at my place). Here is the code: CREATE FUNCTION log_creation (TEXT) RETURNS BOOLEAN AS ' use Sys::Syslog; openlog "PostgreSQL", "pid", "local7"; syslog "info", "Created: %s", $_[0]; closelog; return 1; ' LANGUAGE plperlu; -- Installation on Debian needs: -- apt-get install libpgperl -- /usr/lib/postgresql/bin/createlang plperlu ${MYDATABASE} CREATE FUNCTION do_log () RETURNS OPAQUE AS ' BEGIN PERFORM log_creation(NEW.name); RETURN NEW; END; ' LANGUAGE PLPGSQL; CREATE TRIGGER do_log AFTER INSERT ON Domains FOR EACH ROW EXECUTE PROCEDURE do_log(); > 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" Thanks but, anyway, openlog does not return anything, so global variables would not help. I just call openlog each time, hoping it is not too much overhead.
В списке pgsql-general по дате отправления: