From b259476752810c3522a39c1ea8a1f8f6b27bb5d3 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 28 Feb 2018 14:51:55 +0200 Subject: [PATCH] Bug 16357: (follow-up) Use Koha::Logger and add fatal errors --- debian/templates/plack.psgi | 12 +++++------- etc/log4perl.conf | 7 +++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi index 90d4a266aa..2c65dc7996 100644 --- a/debian/templates/plack.psgi +++ b/debian/templates/plack.psgi @@ -38,13 +38,11 @@ use Koha::Database; use Koha::DateUtils; #BZ 16357, add timestamps to warnings -use Log::Log4perl qw(:easy); -Log::Log4perl->easy_init({ level => $WARN, utf8 => 1 }); -my $logger = Log::Log4perl->get_logger(); # use the default logger style -$SIG{__WARN__} = sub { - my $message = shift; - $logger->warn($message); -}; +use Koha::Logger; + +my $logger = Koha::Logger->get({ interface => 'plack-error' }); +$SIG{__WARN__} = sub { $logger->warn(shift); }; +$SIG{__DIE__} = sub { $logger->fatal(shift); }; use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise { diff --git a/etc/log4perl.conf b/etc/log4perl.conf index efc470746a..bcf81597b2 100644 --- a/etc/log4perl.conf +++ b/etc/log4perl.conf @@ -11,3 +11,10 @@ log4perl.appender.OPAC.filename=__LOG_DIR__/opac-error.log log4perl.appender.OPAC.mode=append log4perl.appender.OPAC.layout=PatternLayout log4perl.appender.OPAC.layout.ConversionPattern=[%d] [%p] %m %l %n + +log4perl.logger.plack-error = WARN, PLACK-ERROR +log4perl.appender.PLACK-ERROR=Log::Log4perl::Appender::File +log4perl.appender.PLACK-ERROR.filename=__LOG_DIR__/plack-error.log +log4perl.appender.PLACK-ERROR.mode=append +log4perl.appender.PLACK-ERROR.layout=PatternLayout +log4perl.appender.PLACK-ERROR.layout.ConversionPattern=[%d] [%p] %m -- 2.11.0