Bugzilla – Attachment 121467 Details for
Bug 28477
INTRANET and OPAC loggers should print to STDERR instead of to file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28477: Add unit test to prove logging to STDERR works
Bug-28477-Add-unit-test-to-prove-logging-to-STDERR.patch (text/plain), 2.49 KB, created by
David Cook
on 2021-05-28 01:27:05 UTC
(
hide
)
Description:
Bug 28477: Add unit test to prove logging to STDERR works
Filename:
MIME Type:
Creator:
David Cook
Created:
2021-05-28 01:27:05 UTC
Size:
2.49 KB
patch
obsolete
>From f048a7e98887bc6e09d5a0e89a7b3f6b3d7db76a Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 28 May 2021 01:26:18 +0000 >Subject: [PATCH] Bug 28477: Add unit test to prove logging to STDERR works > >This patch shows that using the Screen/Stderr=1 Log4perl configuration >with Koha::Logger will output to STDERR. >--- > t/Logger.t | 44 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 43 insertions(+), 1 deletion(-) > >diff --git a/t/Logger.t b/t/Logger.t >index a2a0cc58b8..f8155b6350 100755 >--- a/t/Logger.t >+++ b/t/Logger.t >@@ -22,7 +22,7 @@ use Koha::Logger; > use t::lib::Mocks; > > use File::Temp qw/tempfile/; >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Warn; > > subtest 'Test01 -- Simple tests for Koha::Logger' => sub { >@@ -59,7 +59,49 @@ HERE > "ERROR: Unsupported method catastrophe", > "Undefined method raises warning"; > is( $ret, undef, "'catastrophe' method undefined"); >+}; >+ >+subtest 'Test02 -- Koha::Logger STDERR' => sub { >+ plan tests => 4; >+ >+ my $config_text = <<"HERE" >+log4perl.logger.intranet = WARN, INTRANET >+log4perl.appender.INTRANET=Log::Log4perl::Appender::Screen >+log4perl.appender.INTRANET.stderr=1 >+log4perl.appender.INTRANET.mode=append >+log4perl.appender.INTRANET.layout=PatternLayout >+log4perl.appender.INTRANET.layout.ConversionPattern=[%d] [%p] %m %l %n >+ >+log4perl.logger.opac = WARN, OPAC >+log4perl.appender.OPAC=Log::Log4perl::Appender::Screen >+log4perl.appender.OPAC.stderr=1 >+log4perl.appender.OPAC.mode=append >+log4perl.appender.OPAC.layout=PatternLayout >+log4perl.appender.OPAC.layout.ConversionPattern=[%d] [%p] %m %l %n >+HERE >+; >+ #NOTE: Re-init at this level, since Koha::Logger can't re-init >+ Log::Log4perl->init( \$config_text ); >+ >+ my $opac_logger= Koha::Logger->get({ interface => 'opac' }); >+ is( exists $opac_logger->{logger}, 1, 'Log4perl config found'); >+ my $opac_out; >+ { >+ local *STDERR; >+ open(STDERR,'>>',\$opac_out); >+ $opac_logger->warn('opac-warn'); >+ }; >+ like($opac_out, qr/\Q[WARN] opac-warn\Q/,'OPAC logged to STDERR'); > >+ my $intranet_logger= Koha::Logger->get({ interface => 'intranet' }); >+ is( exists $intranet_logger->{logger}, 1, 'Log4perl config found'); >+ my $intranet_out; >+ { >+ local *STDERR; >+ open(STDERR,'>>',\$intranet_out); >+ $intranet_logger->warn('intranet-warn'); >+ }; >+ like($intranet_out, qr/\Q[WARN] intranet-warn\Q/,'Intranet logged to STDERR'); > }; > > sub mytempfile { >-- >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 28477
:
121466
| 121467