From: Marius Gavrilescu Date: Sat, 8 Feb 2014 20:53:10 +0000 (+0200) Subject: Add access log X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=68d5c3ff4f6e5c7bf1dd92b85e89883f1020aa8f;p=plack-app-gruntmaster.git Add access log --- diff --git a/app.psgi b/app.psgi index b1bd530..64e3f28 100644 --- a/app.psgi +++ b/app.psgi @@ -8,6 +8,9 @@ use Plack::App::Gruntmaster; use Plack::Builder; use Plack::Request; use Digest::SHA qw/sha256/; +use Log::Log4perl; + +use constant ACCESSLOG_FORMAT => '%{X-Forwarded-For}i|%h %u "%r" %>s %b "%{Referer}i" "%{User-agent}i"'; $Apache2::AuthzCaps::rootdir = $Apache2::Authen::Passphrase::rootdir; my $word = qr,(\w+),a; @@ -65,11 +68,15 @@ sub authenticate { 1 } +Log::Log4perl->init('log.conf'); +my $access_logger = Log::Log4perl->get_logger('access'); + builder { + enable 'AccessLog', format => ACCESSLOG_FORMAT, logger => sub { $access_logger->info(@_) }; enable 'ContentLength'; enable_if { $_[0]->{PATH_INFO} =~ qr,^/static/,} Header => set => ['Cache-Control', 'public, max-age=604800']; enable 'Static', path => qr,^/static/,; - enable 'Log4perl', category => 'plack', conf => 'log.conf'; + enable 'Log4perl', category => 'plack'; enable \&require_admin; enable_if \&some_auth_required, 'Auth::Basic', authenticator => \&authenticate, realm => 'Gruntmaster 6000'; Plack::App::Gruntmaster->to_app