From: terry%mozilla.org <> Date: Thu, 27 Jan 2000 05:47:55 +0000 (+0000) Subject: Add a way to log all SQL requests made. X-Git-Tag: bugzilla-2.12~416 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afdd0f2f0d165670329b1c63bbad2f5aebcf60cf;p=thirdparty%2Fbugzilla.git Add a way to log all SQL requests made. --- diff --git a/globals.pl b/globals.pl index 6e42aa1c19..1c8b22cd2c 100644 --- a/globals.pl +++ b/globals.pl @@ -68,10 +68,29 @@ sub ConnectToDatabase { } } +my $dosqllog = (-e "data/sqllog") && (-w "data/sqllog"); + +sub SqlLog { + if ($dosqllog) { + my ($str) = (@_); + open(SQLLOGFID, ">>data/sqllog") || die "Can't write to data/sqllog"; + if (flock(SQLLOGFID,2)) { # 2 is magic 'exclusive lock' const. + print SQLLOGFID time2str("%D %H:%M:%S $$", time()) . ": $str\n"; + } + flock(SQLLOGFID,8); # '8' is magic 'unlock' const. + close SQLLOGFID; + } +} + + + + sub SendSQL { my ($str) = (@_); + SqlLog($str); $::currentquery = $::db->query($str) || die "$str: $::db_errstr"; + SqlLog("Done"); } sub MoreSQLData {