Koha/C4/SIP/Trapper.pm
Tomas Cohen Arazi d0abe773e8
Bug 32612: (QA follow-up) Add POD and fix typo
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-02-07 15:30:29 -03:00

49 lines
767 B
Perl

package C4::SIP::Trapper;
use Modern::Perl;
use Koha::Logger;
=head1 NAME
C4::SIP::Trapper - Module for capturing warnings for the SIP logger
=head2 TIEHANDLE
Ties the given class to this module.
=cut
sub TIEHANDLE {
my $class = shift;
bless [], $class;
}
=head2 PRINT
Captures warnings and directs them to Koha::Logger as well as STDERR
=cut
sub PRINT {
my $self = shift;
$Log::Log4perl::caller_depth++;
my $logger =
Koha::Logger->get( { interface => 'sip', category => 'STDERR' } );
warn @_;
$logger->warn(@_);
$Log::Log4perl::caller_depth--;
}
=head2 BINMODE
Suppress errors from Log::Log4perl::Appender::Screen
=cut
sub BINMODE {
my ( $self, $mode ) = @_;
binmode( STDOUT, $mode );
};
1;