+ binmode(IN, ":utf8");
+
+ # TODO: better filename.
+ open(OUT, ">>debug.log");
+ binmode(OUT, ":utf8");
+ print OUT "DEBUG: $str\n";
+
+ # note: cannot call external functions because SIG{} does not allow us to.
+ my $i;
+ while (<IN>) {
+ chop;
+ $i++;
+ # bleh. this tries to duplicate status().
+ # TODO: statcountfix
+ # TODO: rename to log_*someshit*
+ if ($i == $line) {
+ my $msg = "$file: $i:!$_";
+ printf "%s[%6d]%s %s\n", $_green, $statcount, $ob, $msg;
+ print OUT "DEBUG: $msg\n";
+ $statcount++;
+ next;
+ }
+ if ($i+3 > $line && $i-3 < $line) {
+ my $msg = "$file: $i: $_";
+ printf "%s[%6d]%s %s\n", $_green, $statcount, $ob, $msg;
+ print OUT "DEBUG: $msg\n";
+ $statcount++;
+ }
+ }
+ close IN;
+ close OUT;
+}
+
+sub openSQLDebug {
+ if (!open(SQLDEBUG, ">>$param{'SQLDebug'}")) {
+ &ERROR("Cannot open ($param{'SQLDebug'}): $!");
+ delete $param{'SQLDebug'};
+ return 0;
+ }
+ binmode(SQLDEBUG, ":utf8");
+
+ &status("Opened SQL Debug file: $param{'SQLDebug'}");
+ return 1;
+}
+
+sub closeSQLDebug {
+ close SQLDEBUG;
+
+ &status("Closed SQL Debug file: $param{'SQLDebug'}");
+}
+
+sub SQLDebug {
+ return unless (&IsParam('SQLDebug'));