summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterry%mozilla.org <>2000-01-27 06:47:55 +0100
committerterry%mozilla.org <>2000-01-27 06:47:55 +0100
commitafdd0f2f0d165670329b1c63bbad2f5aebcf60cf (patch)
tree12fe85f7f4959cce0ee0f7c499e470644fd3ed00
parent5bf7869f8b7d8c3bec9552081e13fdebb548b0cb (diff)
downloadbugzilla-afdd0f2f0d165670329b1c63bbad2f5aebcf60cf.tar.gz
bugzilla-afdd0f2f0d165670329b1c63bbad2f5aebcf60cf.tar.xz
Add a way to log all SQL requests made.
-rw-r--r--globals.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/globals.pl b/globals.pl
index 6e42aa1c1..1c8b22cd2 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 {