Handler::Server::Nginx does not use logger config from lemonldap-ng.ini
Concerned version
Version: 2.0.13
Summary
- Using Nginx + FastCGI (Handler::Server::Nginx)
- logs using $self in this objet do not work
# never appears
$self->logger->debug('New request');
This is because the PSGI init() method is called without arguments, so logging gets initialized to Syslog with a default level (info)
- Because of this, it is also impossible to change the logger for the PSGI Server. (setting log4perl etc)
- However, logs emitted by Handler classes ($class->logger) work fine
Possible fixes
in Handler/PSGI.pm:
sub init {
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;
}
Lemonldap::NG::Common::PSGI::init
is called without any args (causing the default logger to be set) because none of the child classes (Handler::Server::Nginx) reads the local config (lemonldap-ng.ini)
lemonldap-ng.ini is read during Lemonldap::NG::Handler::Lib::PSGI::init
, so perhaps we should
- Call
Lemonldap::NG::Handler::Lib::PSGI::init
first - Call
Lemonldap::NG::Common::PSGI::init
next, passing$self->api->localConfig
as an argument, so that the correct logger can be set in $self->logger
What do you think @guimard ? Can changing the order of those two calls cause any trouble? Do you see another solution?