From 46a6bb10e664b2f1f21598078a0636aa8ce5e5e4 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 +++++++ misc/plack/koha.psgi | 12 +++++------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi index 90d4a26..2c65dc7 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 efc4707..bcf8159 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 diff --git a/misc/plack/koha.psgi b/misc/plack/koha.psgi index 8f87dfb..a7989f5 100644 --- a/misc/plack/koha.psgi +++ b/misc/plack/koha.psgi @@ -6,13 +6,11 @@ use Plack::Middleware::Debug; use Plack::App::Directory; #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 lose -utf8 under plack { -- 2.7.4