나는 사용자 정의 아파치 로그 핸들러를 만들려면, 그리고 아파치 사이트에서 발견되는 템플릿은 다음과 같습니다PerlLogHandler 성능 영향을 어떻게 결정합니까?
#file:MyApache2/LogPerUser.pm
#---------------------------
package MyApache2::LogPerUser;
use strict;
use warnings;
use Apache2::RequestRec();
use Apache2::Connection();
use Fcntl qw(:flock);
use File::Spec::Functions qw(catfile);
use Apache2::Const -compile => qw(OK DECLINED);
sub handler {
my $r = shift;
my ($username) = $r->uri =~ m|^/~([^/]+)|;
return Apache2::Const::DECLINED unless defined $username;
my $entry = sprintf qq(%s [%s] "%s" %d %d\n),
$r->connection->remote_ip, scalar(localtime),
$r->uri, $r->status, $r->bytes_sent;
my $log_path = catfile Apache2::ServerUtil::server_root,
"logs", "$username.log";
open my $fh, ">>$log_path" or die "can't open $log_path: $!";
flock $fh, LOCK_EX;
print $fh $entry;
close $fh;
return Apache2::Const::OK;
}
1;
양떼의 성능 비용은 얼마인가? 이 로깅 프로세스가 병렬로 수행되거나 HTTP 요청과 직렬로 처리됩니까? 병렬로 성능은 그다지 중요하지 않지만 사용자가 다른 것을 추가 할 때까지 기다리지 않아도됩니다.