カスタム Apache2 ログ ハンドラーを作成したいのですが、Apache サイトにあるテンプレートは次のとおりです。
#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 要求と並行して行われますか、それとも順次行われますか? 並行して、パフォーマンスはそれほど重要ではありませんが、ユーザーがこのようなものを追加するためにさらに一瞬待つ必要はありません。