Bug 25527: Initialize the logger when required
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 18 May 2020 12:23:42 +0000 (09:23 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 18 May 2020 14:24:47 +0000 (15:24 +0100)
In an OO package, the logger initialization should happen in the
constructor. This is not an OO package and the initialization is
happening on loading it. This is a wrong behaviour and certainly breaks
in environments where initialization cannot happen (package building,
for example). There could be several options to solve this, as it is
used in a single sub on this package, I opted for initializing on that
sub.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/ImportBatch.pm

index 739f9f6..2055a16 100644 (file)
@@ -83,8 +83,6 @@ BEGIN {
        );
 }
 
-our $logger = Koha::Logger->get( { category => 'C4.ImportBatch' } );
-
 =head1 NAME
 
 C4::ImportBatch - manage batches of imported MARC records
@@ -800,6 +798,8 @@ sub BatchCommitItems {
 sub BatchRevertRecords {
     my $batch_id = shift;
 
+    my $logger = Koha::Logger->get( { category => 'C4.ImportBatch' } );
+
     $logger->trace("C4::ImportBatch::BatchRevertRecords( $batch_id )");
 
     my $record_type;