Bugzilla – Attachment 103916 Details for
Bug 15253
Add Koha::Logger based logging for SIP2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15253: Move subs to a new module, allow unit tests to function
Bug-15253-Move-subs-to-a-new-module-allow-unit-tes.patch (text/plain), 4.68 KB, created by
Kyle M Hall (khall)
on 2020-04-29 11:00:28 UTC
(
hide
)
Description:
Bug 15253: Move subs to a new module, allow unit tests to function
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-04-29 11:00:28 UTC
Size:
4.68 KB
patch
obsolete
>From 561926415ec8f5a3b1b8d4c62da266a2312b5d38 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 22 Apr 2019 11:02:42 -0400 >Subject: [PATCH] Bug 15253: Move subs to a new module, allow unit tests to > function > >--- > C4/SIP/Logger.pm | 47 ++++++++++++++++++++++++++++++++++ > C4/SIP/SIPServer.pm | 61 +++------------------------------------------ > C4/SIP/Sip.pm | 4 ++- > 3 files changed, 54 insertions(+), 58 deletions(-) > create mode 100644 C4/SIP/Logger.pm > >diff --git a/C4/SIP/Logger.pm b/C4/SIP/Logger.pm >new file mode 100644 >index 0000000000..8eff6826e2 >--- /dev/null >+++ b/C4/SIP/Logger.pm >@@ -0,0 +1,47 @@ >+#!/usr/bin/perl >+package C4::SIP::Logger; >+ >+use Modern::Perl; >+ >+our $activeSIPServer; >+our $activeLogger; >+ >+=head2 get_SIPServer >+ >+ my $sipServer = C4::SIP::SIPServer::get_SIPServer() >+ >+@RETURNS C4::SIP::SIPServer, the current server's child-process used to handle this SIP-transaction >+ >+=cut >+ >+sub get_SIPServer { >+ return $activeSIPServer; >+} >+ >+sub _set_SIPServer { >+ my ($sipServer) = @_; >+ $activeSIPServer = $sipServer; >+ return $activeSIPServer; >+} >+ >+=head2 get_logger >+ >+ my $logger = C4::SIP::SIPServer::get_logger() >+ >+@RETURNS Koha::Logger, the logger used to log this SIP-transaction >+ >+=cut >+ >+sub get_logger { >+ return $activeLogger; >+} >+ >+sub set_logger { >+ my ($logger) = @_; >+ $activeLogger = $logger; >+ return $activeLogger; >+} >+ >+1; >+ >+__END__ >diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm >index 90484e4391..b2c2539c9d 100755 >--- a/C4/SIP/SIPServer.pm >+++ b/C4/SIP/SIPServer.pm >@@ -17,6 +17,8 @@ use C4::SIP::Sip::Constants qw(:all); > use C4::SIP::Sip::Configuration; > use C4::SIP::Sip::Checksum qw(checksum verify_cksum); > use C4::SIP::Sip::MsgType qw( handle login_core ); >+use C4::SIP::Logger qw(set_logger); >+ > use Koha::Caches; > > use Koha::Logger; >@@ -86,9 +88,6 @@ __PACKAGE__ ->run(@parms); > # Child > # > >-my $activeSIPServer; >-my $activeLogger; >- > # process_request is the callback used by Net::Server to handle > # an incoming connection request. > >@@ -104,7 +103,7 @@ sub process_request { > Koha::Caches->flush_L1_caches(); > > $self->{account} = undef; # Clear out the account from the last request, it may be different >- $self->{logger} = _set_logger( Koha::Logger->get( { interface => 'sip' } ) ); >+ $self->{logger} = set_logger( Koha::Logger->get( { interface => 'sip' } ) ); > > # Flush previous MDCs to prevent accidentally leaking incorrect MDC-entries > Log::Log4perl::MDC->put( "accountid", undef ); >@@ -175,7 +174,7 @@ sub raw_transport { > } > alarm 0; > >- $self->{logger} = _set_logger( >+ $self->{logger} = set_logger( > Koha::Logger->get( > { > interface => 'sip', >@@ -425,58 +424,6 @@ sub get_timeout { > } > } > >-=head2 get_SIPServer >- >- my $sipServer = C4::SIP::SIPServer::get_SIPServer() >- >-@RETURNS C4::SIP::SIPServer, the current server's child-process used to handle this SIP-transaction >- >-=cut >- >-sub get_SIPServer { >- unless($activeSIPServer) { >- my @cc = caller(1); >- die "$cc[3]() asks for \$activeSIPServer, but he is not defined yet"; >- } >- return $activeSIPServer; >-} >- >-sub _set_SIPServer { >- my ($sipServer) = @_; >- unless (blessed($sipServer) && $sipServer->isa('C4::SIP::SIPServer')) { >- my @cc = caller(0); >- die "$cc[3]():> \$sipServer '$sipServer' is not a C4::SIP::SIPServer-object"; >- } >- $activeSIPServer = $sipServer; >- return $activeSIPServer; >-} >- >-=head2 get_logger >- >- my $logger = C4::SIP::SIPServer::get_logger() >- >-@RETURNS Koha::Logger, the logger used to log this SIP-transaction >- >-=cut >- >-sub get_logger { >- unless($activeLogger) { >- my @cc = caller(1); >- die "$cc[3]() asks for \$activeLogger, but he is not defined yet"; >- } >- return $activeLogger; >-} >- >-sub _set_logger { >- my ($logger) = @_; >- unless (blessed($logger) && $logger->isa('Koha::Logger')) { >- my @cc = caller(0); >- die "$cc[3]():> \$logger '$logger' is not a Koha::Logger-object"; >- } >- $activeLogger = $logger; >- return $activeLogger; >-} >- > 1; > > __END__ >diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm >index 38f62a3441..887a5c31fc 100644 >--- a/C4/SIP/Sip.pm >+++ b/C4/SIP/Sip.pm >@@ -15,6 +15,7 @@ use List::Util qw(first); > > use C4::SIP::Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG); > use C4::SIP::Sip::Checksum qw(checksum); >+use C4::SIP::Logger qw(get_logger); > > use base qw(Exporter); > >@@ -215,7 +216,8 @@ sub syslog { > > my $message = @args ? sprintf($mask, @args) : $mask; > >- C4::SIP::SIPServer::get_logger()->$method($message); >+ my $logger = C4::SIP::Logger::get_logger(); >+ $logger->$method($message) if $logger; > } > > 1; >-- >2.24.2 (Apple Git-127)
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 15253
:
45824
|
45825
|
45826
|
58570
|
58571
|
58572
|
58573
|
58582
|
60872
|
65219
|
65220
|
65221
|
65222
|
65223
|
65224
|
65225
|
65226
|
65227
|
65228
|
71702
|
71703
|
74947
|
86573
|
86574
|
87993
|
88383
|
100062
|
100063
|
100379
|
102216
|
102217
|
102218
|
102219
|
103456
|
103457
|
103458
|
103459
|
103462
|
103499
|
103500
|
103501
|
103502
|
103503
|
103599
|
103915
|
103916
|
103917
|
103918
|
103919
|
103920
|
103921
|
104016
|
104667
|
104668
|
104669
|
104670
|
104671
|
104672
|
104673
|
104674
|
111169