Bugzilla – Attachment 88383 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.67 KB, created by
Kyle M Hall (khall)
on 2019-04-22 15:05:08 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:
2019-04-22 15:05:08 UTC
Size:
4.67 KB
patch
obsolete
>From 3b4f051cb67ebd89f0c2b13d5be6f6d6fed395d2 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 | 60 +++------------------------------------------ > C4/SIP/Sip.pm | 4 ++- > 3 files changed, 53 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 2b73b984b2..e3233f3b35 100755 >--- a/C4/SIP/SIPServer.pm >+++ b/C4/SIP/SIPServer.pm >@@ -17,6 +17,7 @@ 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::Logger; > use C4::SIP::Trapper; >@@ -85,9 +86,6 @@ __PACKAGE__ ->run(@parms); > # Child > # > >-my $activeSIPServer; >-my $activeLogger; >- > # process_request is the callback used by Net::Server to handle > # an incoming connection request. > >@@ -100,7 +98,7 @@ sub process_request { > $self->{config} = $config; > > $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 ); >@@ -171,7 +169,7 @@ sub raw_transport { > } > alarm 0; > >- $self->{logger} = _set_logger( >+ $self->{logger} = set_logger( > Koha::Logger->get( > { > interface => 'sip', >@@ -421,58 +419,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 9146ebcd77..79474920b2 100644 >--- a/C4/SIP/Sip.pm >+++ b/C4/SIP/Sip.pm >@@ -14,6 +14,7 @@ use IO::Handle; > > 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); > >@@ -204,7 +205,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.20.1 (Apple Git-117)
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