+ my $date;
+ if ( &IsParam('logType') and $param{'logType'} =~ /DAILY/i ) {
+ $date = sprintf( '%02d:%02d.%02d', ( gmtime $time )[ 2, 1, 0 ] );
+
+ my ( $day, $month, $year ) = ( gmtime $time )[ 3, 4, 5 ];
+ my $newlogDate =
+ sprintf( '%04d%02d%02d', $year + 1900, $month + 1, $day );
+ if ( defined $logDate and $newlogDate != $logDate ) {
+ &closeLog();
+ &compress( $file{log} );
+ &openLog();
+ }
+ }
+ else {
+ $date = $time;
+ }
+
+ printf LOG "%s %s\n", $date, $input;
+}
+
+sub debug_perl {
+ my ($str) = @_;
+
+ return
+ unless (
+ $str =~ /^WARN: Use of uninitialized value .* at (\S+) line (\d+)/ );
+ my ( $file, $line ) = ( $1, $2 );
+ if ( !open( IN, $file ) ) {
+ &status("WARN: cannot open $file: $!");
+ return;
+ }
+ binmode( IN, ':encoding(UTF-8)' );
+
+ # TODO: better filename.
+ open( OUT, '>>debug.log' );
+ binmode( OUT, ':encoding(UTF-8)' );
+ 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;