Initialize with local conf (#1162)

environments/ppa-mbqj77/deployments/1
Xavier Guimard 8 years ago
parent c5626c77b5
commit 64027a901a
  1. 4
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Logger/Apache2.pm
  2. 16
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Logger/Std.pm
  3. 3
      lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm
  4. 10
      lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Init.pm

@ -1,5 +1,9 @@
package Lemonldap::NG::Common::Logger::Apache2;
use Apache2::ServerRec;
sub init{}
sub AUTOLOAD {
shift;
$AUTOLOAD =~ s/.*:://;

@ -1,23 +1,19 @@
package Lemonldap::NG::Common::Logger::Std;
my @LEVEL = (qw(error warn notice info debug));
our $done = 0;
sub import {
sub init {
no warnings 'redefine';
my $level = $_[1] || 'info';
my $level = $_[1]->{logLevel} || 'info';
my $show = 1;
foreach ( @LEVEL ) {
if($show) {
foreach (qw(error warn notice info debug)) {
if ($show) {
eval qq'sub $_ {print STDERR "[$_] \$_[1]\n"}';
}
else {
eval qq'sub $_ {1}';
}
$show = 0 if($level eq $_);
$show = 0 if ( $level eq $_ );
}
die "unknown level $level" if($show);
die "unknown level $level" if ($show);
}
1;

@ -50,8 +50,9 @@ sub init {
foreach my $k ( keys %$args ) {
$self->{$k} = $args->{$k};
}
eval "use $self->{logger} '$self->{logLevel}'";
eval "require $self->{logger}";
die $@ if($@);
$self->logger->init($self);
return 1;
}

@ -34,7 +34,7 @@ sub init($$) {
# Few actions that must be done at server startup:
# * set log level for Lemonldap::NG logs
$class->logLevelInit( $class->localConfig->{logLevel} );
$class->logLevelInit();
# * set server signature
$class->serverSignatureInit unless ( $class->localConfig->{hideSignature} );
@ -47,11 +47,11 @@ sub init($$) {
# @method void logLevelInit
# Set log level for Lemonldap::NG logs
sub logLevelInit {
my ( $class, $level ) = @_;
my ($class) = @_;
my $logger = $class->localConfig->{logger} ||= $class->defaultLogger;
$level ||= 'info';
eval "use $logger '$level'";
die $@ if($@);
eval "require $logger";
die $@ if ($@);
$logger->init( $class->localConfig );
}
# @method void serverSignatureInit

Loading…
Cancel
Save