From e2752d824cc8fe54b7d97308431590bd52f59251 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 9 Mar 2020 09:50:16 -0400 Subject: [PATCH] Bug 15253: Rename syslog() to log() --- C4/SIP/ILS.pm | 30 ++++++------- C4/SIP/ILS/Item.pm | 8 ++-- C4/SIP/ILS/Patron.pm | 8 ++-- C4/SIP/ILS/Transaction/Checkout.pm | 6 +-- C4/SIP/ILS/Transaction/RenewAll.pm | 4 +- C4/SIP/README | 9 +--- C4/SIP/SIPServer.pm | 54 ++++++++++++------------ C4/SIP/Sip.pm | 12 +++--- C4/SIP/Sip/Configuration.pm | 4 +- C4/SIP/Sip/MsgType.pm | 68 +++++++++++++++--------------- 10 files changed, 98 insertions(+), 105 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 034864b824..a613f6732f 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -6,7 +6,7 @@ package C4::SIP::ILS; use warnings; use strict; -use C4::SIP::Sip qw(syslog); +use C4::SIP::Sip qw(log); use Data::Dumper; use C4::SIP::ILS::Item; @@ -47,7 +47,7 @@ sub new { my $type = ref($class) || $class; my $self = {}; $debug and warn "new ILS: INSTITUTION: " . Dumper($institution); - syslog("LOG_DEBUG", "new ILS '%s'", $institution->{id}); + log("LOG_DEBUG", "new ILS '%s'", $institution->{id}); $self->{institution} = $institution; return bless $self, $type; } @@ -82,7 +82,7 @@ sub supports { sub check_inst_id { my ($self, $id, $whence) = @_; if ($id ne $self->{institution}->{id}) { - syslog("LOG_WARNING", "%s: received institution '%s', expected '%s'", $whence, $id, $self->{institution}->{id}); + log("LOG_WARNING", "%s: received institution '%s', expected '%s'", $whence, $id, $self->{institution}->{id}); # Just an FYI check, we don't expect the user to change location from that in SIPconfig.xml } } @@ -167,13 +167,13 @@ sub checkout { push( @{ $patron->{items} }, { barcode => $item_id } ); $circ->desensitize( !$item->magnetic_media ); - syslog( + log( "LOG_DEBUG", "ILS::Checkout: patron %s has checked out %s", $patron_id, join( ', ', map{ $_->{barcode} } @{ $patron->{items} } ) ); } else { - syslog( "LOG_ERR", "ILS::Checkout Issue failed" ); + log( "LOG_ERR", "ILS::Checkout Issue failed" ); } } @@ -219,20 +219,20 @@ sub checkin { if ( !$circ->ok && $circ->alert_type && $circ->alert_type == 98 ) { # data corruption $circ->screen_msg("Checkin failed: data problem"); - syslog( "LOG_WARNING", "Problem with issue_id in issues and old_issues; check the about page" ); + log( "LOG_WARNING", "Problem with issue_id in issues and old_issues; check the about page" ); } elsif ( $data->{messages}->{withdrawn} && !$circ->ok ) { $circ->screen_msg("Item withdrawn, return not allowed"); - syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - item withdrawn"); + log("LOG_DEBUG", "C4::SIP::ILS::Checkin - item withdrawn"); } elsif ( $data->{messages}->{WasLost} && !$circ->ok ) { $circ->screen_msg("Item lost, return not allowed"); - syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - item lost"); + log("LOG_DEBUG", "C4::SIP::ILS::Checkin - item lost"); } elsif ( !$item->{patron} ) { if ( $checked_in_ok ) { # Mark checkin ok although book not checked out $circ->ok( 1 ); - syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - using checked_in_ok"); + log("LOG_DEBUG", "C4::SIP::ILS::Checkin - using checked_in_ok"); } else { $circ->screen_msg("Item not checked out"); - syslog("LOG_DEBUG", "C4::SIP::ILS::Checkin - item not checked out"); + log("LOG_DEBUG", "C4::SIP::ILS::Checkin - item not checked out"); } } elsif ( $circ->ok ) { $circ->patron( $patron = C4::SIP::ILS::Patron->new( $item->{patron} ) ); @@ -244,7 +244,7 @@ sub checkin { # Bug 10748 with pref BlockReturnOfLostItems adds another case to come # here: returning a lost item when the pref is set. $circ->screen_msg("Checkin failed"); - syslog( "LOG_WARNING", "Checkin failed: probably for Wrongbranch or withdrawn" ); + log( "LOG_WARNING", "Checkin failed: probably for Wrongbranch or withdrawn" ); } return $circ; @@ -461,10 +461,10 @@ sub renew { my $count = scalar @{$patron->{items}}; foreach my $i (@{$patron->{items}}) { unless (defined $i->{barcode}) { # FIXME: using data instead of objects may violate the abstraction layer - syslog("LOG_ERR", "No barcode for item %s of %s: $item_id", $j+1, $count); + log("LOG_ERR", "No barcode for item %s of %s: $item_id", $j+1, $count); next; } - syslog("LOG_DEBUG", "checking item %s of %s: $item_id vs. %s", ++$j, $count, $i->{barcode}); + log("LOG_DEBUG", "checking item %s of %s: $item_id vs. %s", ++$j, $count, $i->{barcode}); if ($i->{barcode} eq $item_id) { # We have it checked out $item = C4::SIP::ILS::Item->new( $item_id ); @@ -498,9 +498,9 @@ sub renew_all { $trans->patron($patron = C4::SIP::ILS::Patron->new( $patron_id )); if (defined $patron) { - syslog("LOG_DEBUG", "ILS::renew_all: patron '%s': renew_ok: %s", $patron->name, $patron->renew_ok); + log("LOG_DEBUG", "ILS::renew_all: patron '%s': renew_ok: %s", $patron->name, $patron->renew_ok); } else { - syslog("LOG_DEBUG", "ILS::renew_all: Invalid patron id: '%s'", $patron_id); + log("LOG_DEBUG", "ILS::renew_all: Invalid patron id: '%s'", $patron_id); } if (!defined($patron)) { diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index cc842e8f74..c7d226d662 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -9,7 +9,7 @@ package C4::SIP::ILS::Item; use strict; use warnings; -use C4::SIP::Sip qw(syslog); +use C4::SIP::Sip qw(log); use Carp; use Template; @@ -77,7 +77,7 @@ sub new { my $type = ref($class) || $class; my $item = Koha::Items->find( { barcode => barcodedecode( $item_id ) } ); unless ( $item ) { - syslog("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id); + log("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id); warn "new ILS::Item($item_id) : No item '$item_id'."; return; } @@ -107,7 +107,7 @@ sub new { $self->{author} = $biblio->author; bless $self, $type; - syslog( "LOG_DEBUG", "new ILS::Item('%s'): found with title '%s'", + log( "LOG_DEBUG", "new ILS::Item('%s'): found with title '%s'", $item_id, $self->{title} // '' ); return $self; @@ -181,7 +181,7 @@ sub hold_patron_name { my $holder = Koha::Patrons->find( $borrowernumber ); unless ($holder) { - syslog("LOG_ERR", "While checking hold, failed to retrieve the patron with borrowernumber '$borrowernumber'"); + log("LOG_ERR", "While checking hold, failed to retrieve the patron with borrowernumber '$borrowernumber'"); return; } my $email = $holder->email || ''; diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm index 5193f4fc39..2c7b81d48c 100644 --- a/C4/SIP/ILS/Patron.pm +++ b/C4/SIP/ILS/Patron.pm @@ -12,7 +12,7 @@ use warnings; use Exporter; use Carp; -use C4::SIP::Sip qw(syslog); +use C4::SIP::Sip qw(log); use Data::Dumper; use C4::SIP::Sip qw(add_field); @@ -42,7 +42,7 @@ sub new { || Koha::Patrons->find( { userid => $patron_id } ); $debug and warn "new Patron: " . Dumper($patron->unblessed) if $patron; unless ($patron) { - syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id); + log("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id); return; } $kp = $patron->unblessed; @@ -149,7 +149,7 @@ sub new { $self = \%ilspatron; $debug and warn Dumper($self); - syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id}); + log("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id}); bless $self, $type; return $self; } @@ -404,7 +404,7 @@ sub enable { foreach my $field ('charge_ok', 'renew_ok', 'recall_ok', 'hold_ok', 'inet') { $self->{$field} = 1; } - syslog("LOG_DEBUG", "Patron(%s)->enable: charge: %s, renew:%s, recall:%s, hold:%s", + log("LOG_DEBUG", "Patron(%s)->enable: charge: %s, renew:%s, recall:%s, hold:%s", $self->{id}, $self->{charge_ok}, $self->{renew_ok}, $self->{recall_ok}, $self->{hold_ok}); $self->{screen_msg} = "Enable feature not implemented."; # "All privileges restored."; # TODO: not really affecting patron record diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm index 43282b8949..01f4be2901 100644 --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ b/C4/SIP/ILS/Transaction/Checkout.pm @@ -8,7 +8,7 @@ use warnings; use strict; use POSIX qw(strftime); -use C4::SIP::Sip qw(syslog); +use C4::SIP::Sip qw(log); use Data::Dumper; use CGI qw ( -utf8 ); @@ -47,7 +47,7 @@ sub new { sub do_checkout { my $self = shift; - syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..."); + log('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..."); my $shelf = $self->{item}->hold_shelf; my $barcode = $self->{item}->id; my $patron_barcode = $self->{patron}->id; @@ -103,7 +103,7 @@ sub do_checkout { # We've been returned a case other than those above $self->screen_msg("Item cannot be issued: $confirmation"); $noerror = 0; - syslog('LOG_DEBUG', "Blocking checkout Reason:$confirmation"); + log('LOG_DEBUG', "Blocking checkout Reason:$confirmation"); last; } } diff --git a/C4/SIP/ILS/Transaction/RenewAll.pm b/C4/SIP/ILS/Transaction/RenewAll.pm index deefe07bc8..13a5f16594 100644 --- a/C4/SIP/ILS/Transaction/RenewAll.pm +++ b/C4/SIP/ILS/Transaction/RenewAll.pm @@ -6,7 +6,7 @@ package C4::SIP::ILS::Transaction::RenewAll; use strict; use warnings; -use C4::SIP::Sip qw(syslog); +use C4::SIP::Sip qw(log); use C4::SIP::ILS::Item; @@ -42,7 +42,7 @@ sub do_renew_all { my $item_id = $itemx->{barcode}; my $item = C4::SIP::ILS::Item->new($item_id); if ( !defined($item) ) { - syslog( + log( 'LOG_WARNING', q|renew_all: Invalid item id '%s' associated with patron '%s'|, $item_id, diff --git a/C4/SIP/README b/C4/SIP/README index 73acdfdd9b..b123fca2eb 100644 --- a/C4/SIP/README +++ b/C4/SIP/README @@ -14,11 +14,4 @@ perl modules to run: LOGGING -SIPServer uses syslog() for status and debugging messages. All -syslog messages are logged using the syslog facility 'local6'. -If you need to change this, because something else on your system -is already using that facililty, just change the definition of -'LOG_SIP' at the top of the file SIPServer.pm - -Make sure to update your syslog configuration to capture facility -'local6' and record it. +SIPServer uses Koha::Logger for status and debugging messages. diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index b2c2539c9d..25515d4847 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -12,7 +12,7 @@ use Scalar::Util qw(blessed); require UNIVERSAL::require; use C4::Context; -use C4::SIP::Sip qw(syslog); +use C4::SIP::Sip qw(log); use C4::SIP::Sip::Constants qw(:all); use C4::SIP::Sip::Configuration; use C4::SIP::Sip::Checksum qw(checksum verify_cksum); @@ -125,14 +125,14 @@ sub process_request { $self->{service} = $config->find_service($sockaddr, $port, $proto); if (!defined($self->{service})) { - syslog("LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s", $sockaddr, $port, $proto); + log("LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s", $sockaddr, $port, $proto); die "process_request: Bad server connection"; } $transport = $transports{$self->{service}->{transport}}; if (!defined($transport)) { - syslog("LOG_WARNING", "Unknown transport '%s', dropping", $service->{transport}); + log("LOG_WARNING", "Unknown transport '%s', dropping", $service->{transport}); return; } else { &$transport($self); @@ -158,13 +158,13 @@ sub raw_transport { # In practice it should only iterate once but be prepared local $SIG{ALRM} = sub { die 'raw transport Timed Out!' }; my $timeout = $self->get_timeout({ transport => 1 }); - syslog('LOG_DEBUG', "raw_transport: timeout is $timeout"); + log('LOG_DEBUG', "raw_transport: timeout is $timeout"); alarm $timeout; while (!$self->{account}) { $input = read_request(); if (!$input) { # EOF on the socket - syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); + log("LOG_INFO", "raw_transport: shutting down: EOF during login"); return; } $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) @@ -187,29 +187,29 @@ sub raw_transport { Log::Log4perl::MDC->put( "accountid", $self->{account}->{id} ); Log::Log4perl::MDC->put( "peeraddr", $self->{server}->{peeraddr} ); - syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", + log("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", $self->{account}->{id}, $self->{account}->{institution}); if (! $self->{account}->{id}) { - syslog("LOG_ERR","Login failed shutting down"); + log("LOG_ERR","Login failed shutting down"); return; } $self->sip_protocol_loop(); - syslog("LOG_INFO", "raw_transport: shutting down"); + log("LOG_INFO", "raw_transport: shutting down"); return; } sub get_clean_string { my $string = shift; if (defined $string) { - syslog("LOG_DEBUG", "get_clean_string pre-clean(length %s): %s", length($string), $string); + log("LOG_DEBUG", "get_clean_string pre-clean(length %s): %s", length($string), $string); chomp($string); $string =~ s/^[^A-z0-9]+//; $string =~ s/[^A-z0-9]+$//; - syslog("LOG_DEBUG", "get_clean_string post-clean(length %s): %s", length($string), $string); + log("LOG_DEBUG", "get_clean_string post-clean(length %s): %s", length($string), $string); } else { - syslog("LOG_INFO", "get_clean_string called on undefined"); + log("LOG_INFO", "get_clean_string called on undefined"); } return $string; } @@ -219,7 +219,7 @@ sub get_clean_input { my $in = ; $in = get_clean_string($in); while (my $extra = ){ - syslog("LOG_ERR", "get_clean_input got extra lines: %s", $extra); + log("LOG_ERR", "get_clean_input got extra lines: %s", $extra); } return $in; } @@ -232,7 +232,7 @@ sub telnet_transport { my $input; my $config = $self->{config}; my $timeout = $self->get_timeout({ transport => 1 }); - syslog("LOG_DEBUG", "telnet_transport: timeout is $timeout"); + log("LOG_DEBUG", "telnet_transport: timeout is $timeout"); eval { local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; }; @@ -251,10 +251,10 @@ sub telnet_transport { $pwd = ; alarm 0; - syslog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd)); + log("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd)); $uid = get_clean_string ($uid); $pwd = get_clean_string ($pwd); - syslog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd)); + log("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd)); if (exists ($config->{accounts}->{$uid}) && ($pwd eq $config->{accounts}->{$uid}->{password})) { @@ -263,25 +263,25 @@ sub telnet_transport { last; } } - syslog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||'')); + log("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||'')); print("Invalid login$CRLF"); } }; # End of eval if ($@) { - syslog("LOG_ERR", "telnet_transport: Login timed out"); + log("LOG_ERR", "telnet_transport: Login timed out"); die "Telnet Login Timed out"; } elsif (!defined($account)) { - syslog("LOG_ERR", "telnet_transport: Login Failed"); + log("LOG_ERR", "telnet_transport: Login Failed"); die "Login Failure"; } else { print "Login OK. Initiating SIP$CRLF"; } $self->{account} = $account; - syslog("LOG_DEBUG", "telnet_transport: uname/inst: '%s/%s'", $account->{id}, $account->{institution}); + log("LOG_DEBUG", "telnet_transport: uname/inst: '%s/%s'", $account->{id}, $account->{institution}); $self->sip_protocol_loop(); - syslog("LOG_INFO", "telnet_transport: shutting down"); + log("LOG_INFO", "telnet_transport: shutting down"); return; } @@ -311,7 +311,7 @@ sub sip_protocol_loop { # In short, we'll take any valid message here. eval { local $SIG{ALRM} = sub { - syslog( 'LOG_DEBUG', 'Inactive: timed out' ); + log( 'LOG_DEBUG', 'Inactive: timed out' ); die "Timed Out!\n"; }; my $previous_alarm = alarm($timeout); @@ -323,14 +323,14 @@ sub sip_protocol_loop { alarm($timeout); unless ($inputbuf) { - syslog( "LOG_ERR", "sip_protocol_loop: empty input skipped" ); + log( "LOG_ERR", "sip_protocol_loop: empty input skipped" ); print("96$CR"); next; } my $status = C4::SIP::Sip::MsgType::handle( $inputbuf, $self, q{} ); if ( !$status ) { - syslog( + log( "LOG_ERR", "sip_protocol_loop: failed to handle %s", substr( $inputbuf, 0, 2 ) @@ -369,16 +369,16 @@ sub read_request { # treat as one line to include the extra linebreaks we are trying to remove! } else { - syslog( 'LOG_DEBUG', 'EOF returned on read' ); + log( 'LOG_DEBUG', 'EOF returned on read' ); return; } my $len = length $buffer; if ( $len != $raw_length ) { my $trim = $raw_length - $len; - syslog( 'LOG_DEBUG', "read_request trimmed $trim character(s) " ); + log( 'LOG_DEBUG', "read_request trimmed $trim character(s) " ); } - syslog( 'LOG_INFO', "INPUT MSG: '$buffer'" ); + log( 'LOG_INFO', "INPUT MSG: '$buffer'" ); return $buffer; } @@ -414,7 +414,7 @@ sub get_timeout { my $policy = $server->{policy} // {}; my $rv = sprintf( "%03d", $policy->{timeout} // 0 ); if( length($rv) != 3 ) { - syslog( "LOG_ERR", "Policy timeout has wrong size: '%s'", $rv ); + log( "LOG_ERR", "Policy timeout has wrong size: '%s'", $rv ); return '000'; } return $rv; diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm index 1efa23b7a6..cb67e935a6 100644 --- a/C4/SIP/Sip.pm +++ b/C4/SIP/Sip.pm @@ -22,13 +22,13 @@ use base qw(Exporter); our @EXPORT_OK = qw(y_or_n timestamp add_field maybe_add add_count denied sipbool boolspace write_msg $error_detection $protocol_version $field_delimiter - $last_response syslog); + $last_response log); our %EXPORT_TAGS = ( all => [qw(y_or_n timestamp add_field maybe_add add_count denied sipbool boolspace write_msg $error_detection $protocol_version - $field_delimiter $last_response syslog)]); + $field_delimiter $last_response log)]); our $error_detection = 0; our $protocol_version = 1; @@ -68,7 +68,7 @@ sub add_field { my ($i, $ent); if (!defined($value)) { - syslog("LOG_DEBUG", "add_field: Undefined value being added to '%s'", + log("LOG_DEBUG", "add_field: Undefined value being added to '%s'", $field_id); $value = ''; } @@ -128,7 +128,7 @@ sub add_count { $count = sprintf("%04d", $count); if (length($count) != 4) { - syslog("LOG_WARNING", "handle_patron_info: %s wrong size: '%s'", + log("LOG_WARNING", "handle_patron_info: %s wrong size: '%s'", $label, $count); $count = ' ' x 4; } @@ -199,13 +199,13 @@ sub write_msg { } else { STDOUT->autoflush(1); print $msg, $terminator; - syslog("LOG_INFO", "OUTPUT MSG: '$msg'"); + log("LOG_INFO", "OUTPUT MSG: '$msg'"); } $last_response = $msg; } -sub syslog { +sub log { my ( $level, $mask, @args ) = @_; my $method = diff --git a/C4/SIP/Sip/Configuration.pm b/C4/SIP/Sip/Configuration.pm index c43db38293..13cb9448bf 100644 --- a/C4/SIP/Sip/Configuration.pm +++ b/C4/SIP/Sip/Configuration.pm @@ -10,7 +10,7 @@ use strict; use warnings; use XML::Simple qw(:strict); -use C4::SIP::Sip qw(syslog); +use C4::SIP::Sip qw(log); my $parser = new XML::Simple( KeyAttr => { @@ -65,7 +65,7 @@ sub find_service { my $portstr; foreach my $addr ( '', '*:', "$sockaddr:", "[$sockaddr]:" ) { $portstr = sprintf( "%s%s/%s", $addr, $port, lc $proto ); - syslog( "LOG_DEBUG", + log( "LOG_DEBUG", "Configuration::find_service: Trying $portstr" ); last if ( exists( ( $self->{listeners} )->{$portstr} ) ); } diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 1cfdee6b79..0b8281efb9 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -266,14 +266,14 @@ sub new { # it's using the 2.00 login process, so it must support 2.00. $protocol_version = 2; } - syslog( "LOG_DEBUG", "Sip::MsgType::new('%s', '%s...', '%s'): seq.no '%s', protocol %s", $class, substr( $msg, 0, 10 ), $msgtag, $seqno, $protocol_version ); + log( "LOG_DEBUG", "Sip::MsgType::new('%s', '%s...', '%s'): seq.no '%s', protocol %s", $class, substr( $msg, 0, 10 ), $msgtag, $seqno, $protocol_version ); # warn "SIP PROTOCOL: $protocol_version"; if ( !exists( $handlers{$msgtag} ) ) { - syslog( "LOG_WARNING", "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'", $msgtag, $msg ); + log( "LOG_WARNING", "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'", $msgtag, $msg ); return; } elsif ( !exists( $handlers{$msgtag}->{protocol}->{$protocol_version} ) ) { - syslog( "LOG_WARNING", "new Sip::MsgType: Skipping message '%s' unsupported by protocol rev. '%d'", $msgtag, $protocol_version ); + log( "LOG_WARNING", "new Sip::MsgType: Skipping message '%s' unsupported by protocol rev. '%d'", $msgtag, $protocol_version ); return; } @@ -305,7 +305,7 @@ sub _initialize { $self->{fields}->{$field} = undef; } - syslog( "LOG_DEBUG", "Sip::MsgType::_initialize('%s', '%s', '%s', '%s', ...)", $self->{name}, $msg, $proto->{template}, $proto->{template_len} ); + log( "LOG_DEBUG", "Sip::MsgType::_initialize('%s', '%s', '%s', '%s', ...)", $self->{name}, $msg, $proto->{template}, $proto->{template_len} ); $self->{fixed_fields} = [ unpack( $proto->{template}, $msg ) ]; # see http://perldoc.perl.org/5.8.8/functions/unpack.html @@ -315,9 +315,9 @@ sub _initialize { $fn = substr( $field, 0, 2 ); if ( !exists( $self->{fields}->{$fn} ) ) { - syslog( "LOG_WARNING", "Unsupported field '%s' in %s message '%s'", $fn, $self->{name}, $msg ); + log( "LOG_WARNING", "Unsupported field '%s' in %s message '%s'", $fn, $self->{name}, $msg ); } elsif ( defined( $self->{fields}->{$fn} ) ) { - syslog( "LOG_WARNING", "Duplicate field '%s' (previous value '%s') in %s message '%s'", $fn, $self->{fields}->{$fn}, $self->{name}, $msg ); + log( "LOG_WARNING", "Duplicate field '%s' (previous value '%s') in %s message '%s'", $fn, $self->{fields}->{$fn}, $self->{name}, $msg ); } else { $self->{fields}->{$fn} = substr( $field, 2 ); } @@ -366,7 +366,7 @@ sub handle { $error_detection = 1; if ( !verify_cksum($msg) ) { - syslog( "LOG_WARNING", "Checksum failed on message '%s'", $msg ); + log( "LOG_WARNING", "Checksum failed on message '%s'", $msg ); # REQUEST_SC_RESEND with error detection $last_response = REQUEST_SC_RESEND_CKSUM; @@ -382,7 +382,7 @@ sub handle { # We received a non-ED message when ED is supposed to be active. # Warn about this problem, then process the message anyway. - syslog( "LOG_WARNING", "Received message without error detection: '%s'", $msg ); + log( "LOG_WARNING", "Received message without error detection: '%s'", $msg ); $error_detection = 0; $self = C4::SIP::Sip::MsgType->new( $msg, 0 ); } else { @@ -395,7 +395,7 @@ sub handle { return substr( $msg, 0, 2 ); } unless ( $self->{handler} ) { - syslog( "LOG_WARNING", "No handler defined for '%s'", $msg ); + log( "LOG_WARNING", "No handler defined for '%s'", $msg ); $last_response = REQUEST_SC_RESEND; print("$last_response\r"); return REQUEST_ACS_RESEND; @@ -520,7 +520,7 @@ sub handle_checkout { # Off-line transactions need to be recorded, but there's # not a lot we can do about it - syslog( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} ); + log( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} ); $status = $ils->checkout_no_block( $patron_id, $item_id, $sc_renewal_policy, $trans_date, $nb_due_date ); } else { @@ -647,7 +647,7 @@ sub handle_checkin { if ( $no_block eq 'Y' ) { # Off-line transactions, ick. - syslog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} ); + log( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} ); $status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel ); } else { $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account->{checked_in_ok}, $account->{cv_triggers_alert} ); @@ -766,19 +766,19 @@ sub handle_sc_status { } elsif ( $sc_protocol_version =~ /^2\./ ) { $new_proto = 2; } else { - syslog( "LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version ); + log( "LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version ); $new_proto = 1; } if ( $new_proto != $protocol_version ) { - syslog( "LOG_INFO", "Setting protocol level to $new_proto" ); + log( "LOG_INFO", "Setting protocol level to $new_proto" ); $protocol_version = $new_proto; } if ( $status == SC_STATUS_PAPER ) { - syslog( "LOG_WARNING", "Self-Check unit '%s@%s' out of paper", $self->{account}->{id}, $self->{account}->{institution} ); + log( "LOG_WARNING", "Self-Check unit '%s@%s' out of paper", $self->{account}->{id}, $self->{account}->{institution} ); } elsif ( $status == SC_STATUS_SHUTDOWN ) { - syslog( "LOG_WARNING", "Self-Check unit '%s@%s' shutting down", $self->{account}->{id}, $self->{account}->{institution} ); + log( "LOG_WARNING", "Self-Check unit '%s@%s' shutting down", $self->{account}->{id}, $self->{account}->{institution} ); } $self->{account}->{print_width} = $print_width; @@ -818,10 +818,10 @@ sub login_core { my $pwd = shift; my $status = 1; # Assume it all works if ( !exists( $server->{config}->{accounts}->{$uid} ) ) { - syslog( "LOG_WARNING", "MsgType::login_core: Unknown login '$uid'" ); + log( "LOG_WARNING", "MsgType::login_core: Unknown login '$uid'" ); $status = 0; } elsif ( $server->{config}->{accounts}->{$uid}->{password} ne $pwd ) { - syslog( "LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'" ); + log( "LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'" ); $status = 0; } else { @@ -835,16 +835,16 @@ sub login_core { my $auth_status = api_auth( $uid, $pwd, $inst ); if ( !$auth_status or $auth_status !~ /^ok$/i ) { - syslog( "LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", $uid, $inst, ( $auth_status || 'unknown' ) ); + log( "LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", $uid, $inst, ( $auth_status || 'unknown' ) ); $status = 0; } else { - syslog( "LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst ); + log( "LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst ); # # initialize connection to ILS # my $module = $server->{config}->{institutions}->{$inst}->{implementation}; - syslog( "LOG_DEBUG", 'login_core: ' . Dumper($module) ); + log( "LOG_DEBUG", 'login_core: ' . Dumper($module) ); # Suspect this is always ILS but so we don't break any eccentic install (for now) if ( $module eq 'ILS' ) { @@ -852,14 +852,14 @@ sub login_core { } $module->use; if ($@) { - syslog( "LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", $server->{service}, $module, $inst ); + log( "LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", $server->{service}, $module, $inst ); die("Failed to load ILS implementation '$module' for $inst"); } # like ILS->new(), I think. $server->{ils} = $module->new( $server->{institution}, $server->{account} ); if ( !$server->{ils} ) { - syslog( "LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst ); + log( "LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst ); die("Unable to connect to ILS '$inst'"); } } @@ -882,7 +882,7 @@ sub handle_login { $pwd = $fields->{ (FID_LOGIN_PWD) }; # Terminal PWD, not patron PWD. if ( $uid_algorithm || $pwd_algorithm ) { - syslog( "LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm" ); + log( "LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm" ); $status = 0; } else { $status = login_core( $server, $uid, $pwd ); @@ -921,13 +921,13 @@ sub summary_info { return ''; # No detailed information required } - syslog( "LOG_DEBUG", "Summary_info: index == '%d', field '%s'", $summary_type, $summary_map[$summary_type]->{fid} ); + log( "LOG_DEBUG", "Summary_info: index == '%d', field '%s'", $summary_type, $summary_map[$summary_type]->{fid} ); my $func = $summary_map[$summary_type]->{func}; my $fid = $summary_map[$summary_type]->{fid}; my $itemlist = &$func( $patron, $start, $end, $server ); - syslog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", map{ $_->{barcode} } @{$itemlist} ) ); + log( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", map{ $_->{barcode} } @{$itemlist} ) ); foreach my $i ( @{$itemlist} ) { $resp .= add_field( $fid, $i->{barcode}, $server ); } @@ -1244,7 +1244,7 @@ sub handle_item_status_update { $item_props = $fields->{ (FID_ITEM_PROPS) }; if ( !defined($item_id) ) { - syslog( "LOG_WARNING", "handle_item_status: received message without Item ID field" ); + log( "LOG_WARNING", "handle_item_status: received message without Item ID field" ); } else { $item = $ils->find_item($item_id); } @@ -1289,7 +1289,7 @@ sub handle_patron_enable { $patron_id = $fields->{ (FID_PATRON_ID) }; $patron_pwd = $fields->{ (FID_PATRON_PWD) }; - syslog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd ); + log( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd ); $patron = $ils->find_patron($patron_id); @@ -1359,7 +1359,7 @@ sub handle_hold { } elsif ( $hold_mode eq '*' ) { $status = $ils->alter_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack ); } else { - syslog( "LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", $hold_mode, $server->{account}->{id} ); + log( "LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", $hold_mode, $server->{account}->{id} ); $status = $ils->Transaction::Hold; # new? $status->screen_msg("System error. Please contact library staff."); } @@ -1407,7 +1407,7 @@ sub handle_renew { $ils->check_inst_id( $fields->{ (FID_INST_ID) }, "handle_renew" ); if ( $no_block eq 'Y' ) { - syslog( "LOG_WARNING", "handle_renew: received 'no block' renewal from terminal '%s'", $server->{account}->{id} ); + log( "LOG_WARNING", "handle_renew: received 'no block' renewal from terminal '%s'", $server->{account}->{id} ); } $patron_id = $fields->{ (FID_PATRON_ID) }; @@ -1574,7 +1574,7 @@ sub send_acs_status { $retries = sprintf( "%03d", $policy->{retries} ); if ( length($retries) != 3 ) { - syslog( "LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", $retries ); + log( "LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", $retries ); $retries = '000'; } @@ -1587,7 +1587,7 @@ sub send_acs_status { } elsif ( $protocol_version == 2 ) { $msg .= '2.00'; } else { - syslog( "LOG_ERR", 'Bad setting for $protocol_version, "%s" in send_acs_status', $protocol_version ); + log( "LOG_ERR", 'Bad setting for $protocol_version, "%s" in send_acs_status', $protocol_version ); $msg .= '1.00'; } @@ -1607,7 +1607,7 @@ sub send_acs_status { } } if ( length($supported_msgs) < 16 ) { - syslog( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs ); + log( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs ); } $msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs, $server ); } @@ -1617,7 +1617,7 @@ sub send_acs_status { if ( defined( $account->{print_width} ) && defined($print_line) && $account->{print_width} < length($print_line) ) { - syslog( "LOG_WARNING", "send_acs_status: print line '%s' too long. Truncating", $print_line ); + log( "LOG_WARNING", "send_acs_status: print line '%s' too long. Truncating", $print_line ); $print_line = substr( $print_line, 0, $account->{print_width} ); } @@ -1637,7 +1637,7 @@ sub patron_status_string { my $patron = shift; my $patron_status; - syslog( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok ); + log( "LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok ); $patron_status = sprintf( '%s%s%s%s%s%s%s%s%s%s%s%s%s%s', denied( $patron->charge_ok ), -- 2.21.1 (Apple Git-122.3)