]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Add a way to log all SQL requests made.
authorterry%mozilla.org <>
Thu, 27 Jan 2000 05:47:55 +0000 (05:47 +0000)
committerterry%mozilla.org <>
Thu, 27 Jan 2000 05:47:55 +0000 (05:47 +0000)
globals.pl

index 6e42aa1c199a24ce17a72dac6efdffe6649fb3e1..1c8b22cd2c3e858570a1aa5d8d46884288abf15f 100644 (file)
@@ -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 {