From 20879608f14585570a70256dffc1a2e480eac7df Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Wed, 28 Mar 2018 15:01:32 -0400 Subject: [PATCH] Bug 16357 - Use Koha::Logger via Plack::Middleware::Log4perl Changes plack.psgi to use the Koha::Logger via Plack::Middleware::Log4perl. Changes the log category to 'plack' to be more similar to the existing categories --- debian/templates/log4perl-site.conf.in | 7 +++++++ debian/templates/plack.psgi | 12 +++++------- etc/log4perl.conf | 12 ++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/debian/templates/log4perl-site.conf.in b/debian/templates/log4perl-site.conf.in index efc470746a..91df7d6e1c 100644 --- a/debian/templates/log4perl-site.conf.in +++ b/debian/templates/log4perl-site.conf.in @@ -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 = WARN, PLACK +log4perl.appender.PLACK=Log::Log4perl::Appender::File +log4perl.appender.PLACK.filename=__LOG_DIR__/plack-error.log +log4perl.appender.PLACK.mode=append +log4perl.appender.PLACK.layout=PatternLayout +log4perl.appender.PLACK.layout.ConversionPattern=[%d] [%p] %m diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi index 2c65dc7996..778befd564 100644 --- a/debian/templates/plack.psgi +++ b/debian/templates/plack.psgi @@ -36,14 +36,8 @@ use Koha::Caches; use Koha::Cache::Memory::Lite; use Koha::Database; use Koha::DateUtils; - -#BZ 16357, add timestamps to warnings 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 { no warnings 'redefine'; @@ -72,14 +66,18 @@ my $apiv1 = builder { $server->to_psgi_app; }; +Koha::Logger->get; + builder { enable "ReverseProxy"; enable "Plack::Middleware::Static"; + enable "Log4perl", category => "plack"; + enable "LogErrors"; + enable "LogWarn"; # + is required so Plack doesn't try to prefix Plack::Middleware:: enable "+Koha::Middleware::SetEnv"; mount '/opac' => $opac; mount '/intranet' => $intranet; mount '/api/v1/app.pl' => $apiv1; - }; diff --git a/etc/log4perl.conf b/etc/log4perl.conf index bcf81597b2..91df7d6e1c 100644 --- a/etc/log4perl.conf +++ b/etc/log4perl.conf @@ -12,9 +12,9 @@ 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 +log4perl.logger.plack = WARN, PLACK +log4perl.appender.PLACK=Log::Log4perl::Appender::File +log4perl.appender.PLACK.filename=__LOG_DIR__/plack-error.log +log4perl.appender.PLACK.mode=append +log4perl.appender.PLACK.layout=PatternLayout +log4perl.appender.PLACK.layout.ConversionPattern=[%d] [%p] %m -- 2.11.0