Skip to content

Commit

Permalink
added the new option 'log_successful_requests' #454
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaku committed May 29, 2023
1 parent 7dd068a commit f870849
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/HTTPServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ sub logger {
if($main::config{httpd_builtin}->{log_file}) {
if(open(OUT, ">> $main::config{httpd_builtin}->{log_file}")) {
if($type eq "OK") {
print OUT localtime() . " - $type - [$ENV{REMOTE_ADDR}] \"$ENV{REQUEST_METHOD} $url - " . ($ENV{HTTP_USER_AGENT} || "") . "\"\n";
if(lc($main::config{httpd_builtin}->{log_successful_requests} || "") ne "n") {
print OUT localtime() . " - $type - [$ENV{REMOTE_ADDR}] \"$ENV{REQUEST_METHOD} $url - " . ($ENV{HTTP_USER_AGENT} || "") . "\"\n";
}
} elsif($type eq "NOTEXIST") {
print OUT localtime() . " - $type - [$ENV{REMOTE_ADDR}] File does not exist: $url\n";
} elsif($type eq "AUTHERR") {
Expand All @@ -52,7 +54,9 @@ sub logger {
} else {
my $msg;
if($type eq "OK") {
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] \"$ENV{REQUEST_METHOD} $url - " . ($ENV{HTTP_USER_AGENT} || "") . "\"\n";
if(lc($main::config{httpd_builtin}->{log_successful_requests} || "") ne "n") {
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] \"$ENV{REQUEST_METHOD} $url - " . ($ENV{HTTP_USER_AGENT} || "") . "\"\n";
}
} elsif($type eq "NOTEXIST") {
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] File does not exist: $url\n";
} elsif($type eq "AUTHERR") {
Expand All @@ -62,7 +66,7 @@ sub logger {
} else {
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] $url\n";
}
print("$msg");
print("$msg") if $msg;
}
}

Expand Down

0 comments on commit f870849

Please sign in to comment.