]> iEval git - gruntmaster-page.git/commitdiff
Add access log
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 8 Feb 2014 20:53:10 +0000 (22:53 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 8 Feb 2014 20:53:10 +0000 (22:53 +0200)
app.psgi

index b1bd530dffa5fb4db7bb074a0005b5bb8a757921..64e3f289cbd6ae69fa5cf61137f760815e99a7d1 100644 (file)
--- 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
This page took 0.026337 seconds and 4 git commands to generate.