From d20489ba9acbb283929454c167d404eb07c9dfe2 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Tue, 10 Sep 2013 19:44:29 +0000 Subject: [PATCH] Insert applied rule number in logs (debug mode) --- lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm | 7 +++++-- lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm index 46218a4f3..47b0483a7 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Simple.pm @@ -1505,9 +1505,12 @@ sub isUnprotected { sub grant { my ( $class, $uri ) = splice @_; for ( my $i = 0 ; $i < $locationCount ; $i++ ) { - return &{ $locationCondition->[$i] }($datas) - if ( $uri =~ $locationRegexp->[$i] ); + if ( $uri =~ $locationRegexp->[$i] ) { + $class->lmLog( 'debug', 'Regexp ' . ( $i + 1 ) . ' match' ); + return &{ $locationCondition->[$i] }($datas); + } } + $class->lmLog( 'debug', 'Apply default rule' ); return &$defaultCondition($datas); } diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm index c4f8d21ed..2880cdb30 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Vhost.pm @@ -173,6 +173,7 @@ sub grant { my $vhost = $apacheRequest->hostname; for ( my $i = 0 ; $i < $locationCount->{$vhost} ; $i++ ) { if ( $uri =~ $locationRegexp->{$vhost}->[$i] ) { + $class->lmLog( 'debug', "$vhost: Regexp " . ( $i + 1 ) . ' match' ); return &{ $locationCondition->{$vhost}->[$i] }($datas); } } @@ -183,6 +184,7 @@ sub grant { ); return 0; } + $class->lmLog( 'debug', "$vhost: Apply default rule" ); return &{ $defaultCondition->{$vhost} }($datas); }