@@ -64,6 +64,8 @@ use VWF::Utils;
6464Readonly my $MAX_REQUESTS => 100; # Max requests allowed
6565Readonly my $TIME_WINDOW => 10 * 60; # Time window in seconds (10 minutes)
6666
67+ sub vwflog ($$$$$$); # Ensure all arguments are given
68+
6769my $info = CGI::Info-> new();
6870my $config ;
6971my @suffixlist = (' .pl' , ' .fcgi' );
@@ -599,30 +601,30 @@ sub filter
599601}
600602
601603# Put something to vwf.log
602- sub vwflog
604+ sub vwflog ($$$$$$)
603605{
604606 my ($vwflog , $info , $lingua , $syslog , $message , $log ) = @_ ;
605607
606608 $message ||= ' ' ;
607609
608610 if (!-r $vwflog ) {
609611 # First run - put in the heading row
610- open (my $log , ' >' , $vwflog );
611- print $log ' "domain_name","time","IP","country","type","language","http_code","template","args","warnings","error"' ,
612+ open (my $fout , ' >' , $vwflog );
613+ print $fout ' "domain_name","time","IP","country","type","language","http_code","template","args","warnings","error"' ,
612614 " \n " ;
613- close $log ;
615+ close $fout ;
614616 }
615617
616- if ($vwflog && open (my $log , ' >>' , $vwflog )) {
617- print $log
618+ if ($vwflog && open (my $fout , ' >>' , $vwflog )) {
619+ print $fout
618620 ' "' , $info -> domain_name(), ' ",' ,
619621 ' "' , strftime(' %F %T' , localtime ), ' ",' ,
620622 ' "' , ($ENV {REMOTE_ADDR } ? $ENV {REMOTE_ADDR } : ' ' ), ' ",' ,
621623 ' "' , $lingua -> country(), ' ",' ,
622624 ' "' , $info -> browser_type(), ' ",' ,
623625 ' "' , $lingua -> language(), ' ",' ,
624626 $info -> status(), ' ,' ,
625- ' "' , $log -> template() ? $log -> template() : ' ' , ' ",' ,
627+ ' "' , ( $log -> template() ? $log -> template() : ' ' ) , ' ",' ,
626628 ' "' , $info -> as_string(raw => 1), ' ",' ,
627629 ' "' , $info -> warnings_as_string(), ' ",' ,
628630 ' "' , $message , ' "' ,
@@ -644,7 +646,7 @@ sub vwflog
644646 $info -> browser_type(),
645647 $lingua -> language(),
646648 $info -> status(),
647- $log -> template() ? $log -> template() : ' ' ,
649+ ( $log -> template() ? $log -> template() : ' ' ) ,
648650 $info -> as_string(raw => 1),
649651 $info -> warnings_as_string(),
650652 ' "' , $message , ' "'
0 commit comments