[Koha] export_records.pl
Сычев Игорь Алексеевич
ias at tpu.ru
Thu Feb 20 21:36:30 NZDT 2025
Hi, Andreas!
Thanks for the answer!
-----Original Message-----
From: Andreas Roussos <a.roussos at dataly.gr>
Sent: Sunday, February 16, 2025 5:46 AM
To: Сычев Игорь Алексеевич <ias at tpu.ru>; koha at lists.katipo.co.nz
Subject: Re: [Koha] export_records.pl
Hi Igor, All,
The actual record exporting (in export_records.pl or via the Staff
Interface) is carried out by Koha::Exporter::Record::export(), which is in fact capable of detecting warnings reported by Perl's MARC modules, such as an invalid record length of more than 99999 bytes when exporting to MARC/ISO2709:
Excerpt from Koha/Exporter/Record.pm:
191 my $errorcount_on_decode = eval { scalar( MARC::File::USMARC->decode( $record->as_usmarc )->warnings() ) };
192 if ( $errorcount_on_decode or $@ ) {
193 my $msg = "Record $record_id could not be exported.
" . ( $@ // '' );
194 chomp $msg;
195 Koha::Logger->get->info($msg);
196 next;
197 }
The 'Koha Logger' page in the Koha Community Wiki reads [1]: "By default, only messages of warn, error or fatal will be logged in Koha.
To reveal less severe messages a Koha admin will need to modify the Koha's Log4Perl configuration file."
That's why you don't see anything in the Koha system logs: line 195 above sets the severity to 'info' (which is lower than 'warn') and therefore the message never gets logged.
If you modify line 195 so that it reads:
195 Koha::Logger->get->warn($msg);
you'll get something useful in your intranet-error.log, but only when exporting via the Staff Interface.
However, thanks to Bug 14751 - Allow C4::Context->interface to be set to 'sip' or 'commandline' [2], we can define a new section in our Log4perl configuration file so that log messages from Koha command-line utilities will be logged appropriately.
Try adding the following lines to your
/etc/koha/sites/<instance>/log4perl.conf (replacing <instance> with your actual Koha instance name), and then restart the koha-common service.
When you next invoke the export_records.pl script and it encounters a warning, it will log it at /var/log/koha/<instance>/commandline-error.log.
log4perl.logger.commandline = INFO, COMMANDLINE log4perl.appender.COMMANDLINE=Log::Log4perl::Appender::File
log4perl.appender.COMMANDLINE.filename=/var/log/koha/<instance>/commandline-error.log
log4perl.appender.COMMANDLINE.mode=append
log4perl.appender.COMMANDLINE.layout=PatternLayout
log4perl.appender.COMMANDLINE.layout.ConversionPattern=[%d] [%p] %m %l%n
log4perl.appender.COMMANDLINE.utf8=1
I hope this helps!
Kind regards,
Andreas
[1] https://wiki.koha-community.org/wiki/Koha_Logger
[2] https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14751
More information about the Koha
mailing list