From 1e3d5d2eb89673c252fe7f192de88f00d36858ab Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 16 Apr 2020 16:50:58 +0200 Subject: [PATCH] Bug 25172: Make Koha::Logger explode if init went wrong We do not want to fail silently for the logger. --- Koha/Logger.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Koha/Logger.pm b/Koha/Logger.pm index 1680dff6de..fb545af544 100644 --- a/Koha/Logger.pm +++ b/Koha/Logger.pm @@ -118,18 +118,19 @@ sub DESTROY { } sub _init { - my $log4perl_config_filepath = + #my $env_LOG4PERL_CONF = exists $ENV{LOG4PERL_CONF} ? $ENV{LOG4PERL_CONF} : undef; + my $log4perl_config = exists $ENV{"LOG4PERL_CONF"} - and $ENV{'LOG4PERL_CONF'} - and -s $ENV{"LOG4PERL_CONF"} + && $ENV{'LOG4PERL_CONF'} + && -s $ENV{"LOG4PERL_CONF"} # Check for web server level configuration first # In this case we ASSUME that you correctly arranged logfile # permissions. If not, log4perl will crash on you. - ? Log::Log4perl->init_once( $ENV{"LOG4PERL_CONF"} ); + ? $ENV{"LOG4PERL_CONF"} : C4::Context->config("log4perl_conf"); # This will explode with the relevant error message if something is wrong in the config file - return Log::Log4perl->init_once($conf); + return Log::Log4perl->init_once($log4perl_config); } sub _recheck_logfile { # recheck saved logfile when logging message -- 2.20.1