Commit b31635c6 authored by Yadd's avatar Yadd

Force syslog when FastCGI in use (#1162)

parent fc152768
......@@ -33,7 +33,6 @@ useRedirectOnError = 0
[manager]
protection = manager
logLevel = error
staticPrefix = /static
languages = fr, en
templateDir = __pwd__/lemonldap-ng-manager/site/templates
......
......@@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "llng-fastcgi-server 1"
.TH llng-fastcgi-server 1 "2017-02-11" "perl v5.24.1" "User Contributed Perl Documentation"
.TH llng-fastcgi-server 1 "2017-02-14" "perl v5.24.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
......
......@@ -17,6 +17,7 @@ our (
my %_apps;
$SIG{'PIPE'} = 'IGNORE';
$ENV{LLNG_DEFAULTLOGGER} ||= 'Lemonldap::NG::Common::Logger::Syslog';
$foreground = 0;
$engine ||= $ENV{ENGINE} || 'FCGI';
......
......@@ -13,14 +13,16 @@ sub new {
else {
$self->{facility} = $conf->{syslogFacility} || 'daemon';
}
openlog( 'LLNG', 'cons,pid,ndelay', $self->{facility} );
eval { openlog( 'LLNG', 'cons,pid,ndelay', $self->{facility} ) };
no warnings 'redefine';
my $show = 1;
foreach (qw(error warn notice info debug)) {
if ($show) {
my $name = $_;
$name = 'warning' if ( $_ eq 'warn' );
eval qq'sub $_ {syslog("$name|\$[0]->{facility}",\$_[1])}';
$name = 'err' if ( $_ eq 'error' );
eval qq'sub $_ {syslog("$name|".\$_[0]->{facility},\$_[1])}';
die $@ if($@);
}
else {
eval qq'sub $_ {1}';
......
......@@ -34,14 +34,19 @@ sub init {
foreach my $k ( keys %$args ) {
$self->{$k} = $args->{$k} unless ( $k eq 'logger' );
}
my $logger = $args->{logger} || 'Lemonldap::NG::Common::Logger::Std';
eval "require $logger";
die $@ if ($@);
$self->logger( $logger->new($self) );
$logger = $args->{userLogger} || $logger;
eval "require $logger";
die $@ if ($@);
$self->userLogger( $logger->new( $self, user => 1 ) );
unless ( $self->logger and $self->userLogger ) {
my $logger =
$args->{logger}
|| $ENV{LLNG_DEFAULTLOGGER}
|| 'Lemonldap::NG::Common::Logger::Std';
eval "require $logger";
die $@ if ($@);
$self->logger( $logger->new($self) );
$logger = $ENV{LLNG_USERLOGGER} || $args->{userLogger} || $logger;
eval "require $logger";
die $@ if ($@);
$self->userLogger( $logger->new( $self, user => 1 ) );
}
return 1;
}
......
......@@ -25,12 +25,18 @@ use constant SERVER_ERROR => Apache2::Const::SERVER_ERROR;
use constant AUTH_REQUIRED => Apache2::Const::AUTH_REQUIRED;
use constant MAINTENANCE => Apache2::Const::HTTP_SERVICE_UNAVAILABLE;
use constant BUFF_LEN => 8192;
# Set default logger
use constant defaultLogger => 'Lemonldap::NG::Common::Logger::Apache2';
# Set also default logger for PSGI launched in the same Perl process
$ENV{LLNG_DEFAULTLOGGER} = 'Lemonldap::NG::Common::Logger::Apache2';
eval { require threads::shared; };
our $request; # Apache2::RequestRec object for current request
#*run = \&Lemonldap::NG::Handler::Main::run;
## @rmethod protected int redirectFilter(string url, Apache2::Filter f)
......
......@@ -9,9 +9,10 @@ extends 'Lemonldap::NG::Handler::Lib::PSGI', 'Lemonldap::NG::Common::PSGI';
our $VERSION = '2.0.0';
sub init {
$_[0]->api('Lemonldap::NG::Handler::PSGI::Main') unless ( $_[0]->api );
my $tmp = ( $_[0]->Lemonldap::NG::Common::PSGI::init( $_[1] )
and $_[0]->Lemonldap::NG::Handler::Lib::PSGI::init( $_[1] ) );
my ($self,$args)=@_;
$self->api('Lemonldap::NG::Handler::PSGI::Main') unless ( $self->api );
my $tmp = ( $self->Lemonldap::NG::Common::PSGI::init( $args )
and $self->Lemonldap::NG::Handler::Lib::PSGI::init( $args ) );
return $tmp;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment