Koha/C4/SIP/Logger.pm
Joonas Kylmälä 082da615e6
Bug 25992: Make SIP2 logger subroutines exportable to prevent crash
If the subroutines are not exportable we get the following crash:

> Undefined subroutine &C4::SIP::SIPServer::set_logger

To test:
 In kohadevbox run for example:
 $ ps -aux # check that no existing sip server is running, kill the process if exists
 $ perl /kohadevbox/koha/C4/SIP/SIPServer.pm /etc/koha/sites/kohadev/SIPconfig.xml
 $ koha/misc/sip_cli_emulator.pl -su koha -sp koha -l CPL -a 127.0.0.1 -p 6001 --item 3999900000001 -m item_information

 After applying this patch the Undefined subroutine error should be gone.
 Note: when using the sip_cli_emulator.pl the credentials can be anything.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-07-16 15:26:47 +01:00

70 lines
1.2 KiB
Perl

#!/usr/bin/perl
package C4::SIP::Logger;
use Modern::Perl;
use base 'Exporter';
our @EXPORT_OK = qw ( get_logger set_logger );
our $activeSIPServer;
our $activeLogger;
=head1 NAME
C4::SIP::Logger - Module for handling SIP server logging
=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;
}
=head2 _set_SIPServer
my $sipServer = C4::SIP::SIPServer::_set_SIPServer($sipServer)
Sets the passed in SIP server as the active SIP server and returns it as well
@RETURNS C4::SIP::SIPServer, the current server's child-process used to handle this SIP-transaction
=cut
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;
}
=head2 set_logger
my $logger = C4::SIP::SIPServer::set_logger($logger)
=cut
sub set_logger {
my ($logger) = @_;
$activeLogger = $logger;
return $activeLogger;
}
1;
__END__