Commit afdd0f2f authored by terry%mozilla.org's avatar terry%mozilla.org

Add a way to log all SQL requests made.

parent 5bf7869f
...@@ -68,10 +68,29 @@ sub ConnectToDatabase { ...@@ -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 { sub SendSQL {
my ($str) = (@_); my ($str) = (@_);
SqlLog($str);
$::currentquery = $::db->query($str) $::currentquery = $::db->query($str)
|| die "$str: $::db_errstr"; || die "$str: $::db_errstr";
SqlLog("Done");
} }
sub MoreSQLData { sub MoreSQLData {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment