[Koha-bugs] [Bug 16304] New: Koha::Logger, lazy load loggers so environment can be properly set.

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Apr 20 01:01:29 CEST 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304

            Bug ID: 16304
           Summary: Koha::Logger, lazy load loggers so environment can be
                    properly set.
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: gmcharlt at gmail.com
          Reporter: olli-antti.kivilahti at jns.fi
        QA Contact: testopia at bugs.koha-community.org

If you instantiate Koha::Loggers before having set the C4::Context->interface,
their interface defaults to 'opac'.

This is rather undesired especially for 'commandline' scripts such as cronjobs.

A solution to this is to lazyLoad loggers when they are really needed.
LazyLoading might also have a performance boost when using packages that
initialize a package-level logger but which never gets used.

see t/Koha/Logger.t on how to replicate this issue, but here is a nutshell of
how to replicate this issue:


@@ file A.pm
package A;

use Koha::Logger;
my $logger = Koha::Logger->get({category => __PACKAGE__}); #interface unknown

sub doStuff {
    $logger->error('My interface is always "opac"');
}


@@ script run.pl
use C4::Context;
C4::Context->interface('commandline');

use A;
A::doStuff(); #error is logged using the "opac"-interface instead
              #of the "commandline"-interface

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list