X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FSIP%2FSip.pm;h=4e3f299afb5eec008531e629deb8052e5ddd9e8d;hb=ef038b258ebfef315cea06bcf27d92eada86e9d7;hp=8a0f067dacf7a21fcd5aeef18ce97a87dd2b51c3;hpb=2a3f7c141798121a75fc9ee670af0fdde431d9c2;p=koha_fer diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm index 8a0f067dac..4e3f299afb 100644 --- a/C4/SIP/Sip.pm +++ b/C4/SIP/Sip.pm @@ -12,6 +12,7 @@ use Exporter; use Sys::Syslog qw(syslog); use POSIX qw(strftime); use Socket qw(:crlf); +use IO::Handle; use Sip::Constants qw(SIP_DATETIME); use Sip::Checksum qw(checksum); @@ -49,7 +50,9 @@ our $last_response = ''; sub timestamp { my $time = $_[0] || time(); - if ($time=~m/^(\d{4})\-(\d{2})\-(\d{2})/) { + if ( ref $time eq 'DateTime') { + return $time->strftime(SIP_DATETIME); + } elsif ($time=~m/^(\d{4})\-(\d{2})\-(\d{2})/) { # passing a db returned date as is + bogus time return sprintf( '%04d%02d%02d 235900', $1, $2, $3); } @@ -230,9 +233,11 @@ sub write_msg { if ($file) { + $file->autoflush(1); print $file "$msg\r"; } else { - print "$msg\r"; + STDOUT->autoflush(1); + print $msg, "\r"; syslog("LOG_INFO", "OUTPUT MSG: '$msg'"); }