Bugzilla – Attachment 106319 Details for
Bug 16357
Plack error logs are not time stamped
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16357: [Alternative] Override __WARN__ in Plack to use Log4Perl
Bug-16357-Alternative-Override-WARN-in-Plack-to-us.patch (text/plain), 4.11 KB, created by
Arthur Suzuki
on 2020-06-26 09:26:18 UTC
(
hide
)
Description:
Bug 16357: [Alternative] Override __WARN__ in Plack to use Log4Perl
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2020-06-26 09:26:18 UTC
Size:
4.11 KB
patch
obsolete
>From 4bd392b3d8cdbd3a43e6760140c4e3a2771c816e Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Mon, 22 Jun 2020 03:53:16 +0000 >Subject: [PATCH] Bug 16357: [Alternative] Override __WARN__ in Plack to use > Log4Perl > >This patch overrides __WARN__ in Plack to use Log4Perl to add >timestamps to error output. The Log4Perl config uses a screen >appender so the output still goes to STDERR so that it is still >managed by Starman. > >This patch adds a Plack::Middleware::LogWarn package dependency. >(The dependency is very simplistic, so we could always do out own > version if we would prefer to skip the external dependency.) > >To Test: >0) apt-get install libplack-middleware-logwarn-perl >1) Apply patch >2) Copy PLACK block from etc/log4perl.conf to >/etc/koha/sites/kohadev/log4perl.conf >3) Copy debian/templates/plack.psgi to /etc/koha/sites/kohadev/plack.psgi >4) Create some output on STDERR (it might be necessary to add >a 'warn "TEST";' line to the intranet or OPAC) >5) koha-plack --restart kohadev >6) Open /var/log/koha/kohadev/plack-error.log >7) Observe a log line like the following: >[2020/06/22 03:51:23] [WARN] TEST at /kohadevbox/koha/opac/opac-user.pl line 59. > >Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> >--- > debian/control | 2 ++ > debian/templates/log4perl-site.conf.in | 8 ++++++++ > debian/templates/plack.psgi | 5 +++++ > etc/log4perl.conf | 8 ++++++++ > 4 files changed, 23 insertions(+) > >diff --git a/debian/control b/debian/control >index c42a69b4a4..1c6af74557 100644 >--- a/debian/control >+++ b/debian/control >@@ -110,6 +110,7 @@ Build-Depends: libalgorithm-checkdigits-perl, > libpdf-reuse-barcode-perl, > libpdf-reuse-perl, > libpdf-table-perl, >+ libplack-middleware-logwarn-perl, > libplack-middleware-reverseproxy-perl, > libppi-perl, > libreadonly-perl, >@@ -344,6 +345,7 @@ Depends: libalgorithm-checkdigits-perl, > libpdf-reuse-barcode-perl, > libpdf-reuse-perl, > libpdf-table-perl, >+ libplack-middleware-logwarn-perl, > libplack-middleware-reverseproxy-perl, > libppi-perl, > libreadonly-perl, >diff --git a/debian/templates/log4perl-site.conf.in b/debian/templates/log4perl-site.conf.in >index df61c9a9ec..b893241559 100644 >--- a/debian/templates/log4perl-site.conf.in >+++ b/debian/templates/log4perl-site.conf.in >@@ -37,3 +37,11 @@ log4perl.appender.SIP.mode=append > log4perl.appender.SIP.layout=PatternLayout > log4perl.appender.SIP.layout.ConversionPattern=[%d] [%p] %m %l %n > log4perl.appender.SIP.utf8=1 >+ >+log4perl.logger.plack = WARN, PLACK >+log4perl.appender.PLACK=Log::Log4perl::Appender::Screen >+log4perl.appender.PLACK.stderr = 1 >+log4perl.appender.PLACK.mode=append >+log4perl.appender.PLACK.layout=PatternLayout >+log4perl.appender.PLACK.layout.ConversionPattern=[%d] [%p] %m >+log4perl.appender.PLACK.utf8=1 >diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi >index cde680ee30..c06ff4b913 100644 >--- a/debian/templates/plack.psgi >+++ b/debian/templates/plack.psgi >@@ -36,6 +36,7 @@ use Koha::Caches; > use Koha::Cache::Memory::Lite; > use Koha::Database; > use Koha::DateUtils; >+use Koha::Logger; > > use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise > { >@@ -65,9 +66,13 @@ my $apiv1 = builder { > $server->to_psgi_app; > }; > >+Koha::Logger->get; >+ > builder { > enable "ReverseProxy"; > enable "Plack::Middleware::Static"; >+ enable "Log4perl", category => "plack"; >+ enable "LogWarn"; > > # + is required so Plack doesn't try to prefix Plack::Middleware:: > enable "+Koha::Middleware::SetEnv"; >diff --git a/etc/log4perl.conf b/etc/log4perl.conf >index df61c9a9ec..b893241559 100644 >--- a/etc/log4perl.conf >+++ b/etc/log4perl.conf >@@ -37,3 +37,11 @@ log4perl.appender.SIP.mode=append > log4perl.appender.SIP.layout=PatternLayout > log4perl.appender.SIP.layout.ConversionPattern=[%d] [%p] %m %l %n > log4perl.appender.SIP.utf8=1 >+ >+log4perl.logger.plack = WARN, PLACK >+log4perl.appender.PLACK=Log::Log4perl::Appender::Screen >+log4perl.appender.PLACK.stderr = 1 >+log4perl.appender.PLACK.mode=append >+log4perl.appender.PLACK.layout=PatternLayout >+log4perl.appender.PLACK.layout.ConversionPattern=[%d] [%p] %m >+log4perl.appender.PLACK.utf8=1 >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16357
:
71752
|
71753
|
71871
|
72290
|
72296
|
73404
|
77529
|
77530
|
77531
|
77532
|
77533
|
106141
|
106313
|
106319
|
106320
|
109053
|
109054
|
109055
|
109056
|
109060
|
109067
|
109068
|
109133
|
109215
|
110107
|
110108
|
110109
|
110249
|
110250
|
110251
|
110252
|
110253
|
110254