[Bug 16304] New: Koha::Logger, lazy load loggers so environment can be properly set.
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@gmail.com Reporter: olli-antti.kivilahti@jns.fi QA Contact: testopia@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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |14167 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14167 [Bug 14167] Add Koha::Logger based on Log4perl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Koha::Logger, lazy load |Koha::Logger, lazy load |loggers so environment can |loggers so environment has |be properly set. |time to get set -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 --- Comment #1 from Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> --- Created attachment 50449 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=50449&action=edit Bug 16304 - Koha::Logger, lazy load loggers so environment has time to get set 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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |olli-antti.kivilahti@jns.fi -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |16302 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16302 [Bug 16302] Koha::Logger performance tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 --- Comment #2 from Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> --- You can also circumvent this environment setting problem with this code block: Use C4::Context; BEGIN { C4::Context->interface('commandline'); } use Logger_Invoking_Module; But this is dependent on the load order of Perl modules and is practically impossible to know if you are just starting to work with Koha / new to Perl. BEGIN { C4::Context->interface('commandline'); } Use C4::Context; use Logger_Invoking_Module; This no longer works. Also lazyLoading saves CPU time on package-level $loggers which might not get used. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |16312 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16312 [Bug 16312] Koha::Logger overload configuration for command line scripts verbosity levels -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |16313 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16313 [Bug 16313] Koha::Logger doesn't forward the Log::Log4perl::Logger return value -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #50449|0 |1 is obsolete| | --- Comment #3 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 64845 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=64845&action=edit Bug 16304 - Koha::Logger, lazy load loggers so environment has time to get set 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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lari.taskula@jns.fi --- Comment #4 from Lari Taskula <lari.taskula@jns.fi> --- Fixed a conflict when applying patch. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de Status|Needs Signoff |BLOCKED --- Comment #5 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Depends on bug 16312 which is Failed QA. Marking BLOCKED until dependency can be resolved. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|BLOCKED |NEW --- Comment #6 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- (In reply to Katrin Fischer from comment #5)
Depends on bug 16312 which is Failed QA. Marking BLOCKED until dependency can be resolved.
Depeneny is set to NEW now, removing blocked in favor of new here as well. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16304 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |42837 CC| |martin.renvoize@openfifth.c | |o.uk Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42837 [Bug 42837] Improve and extend systems/developer facing logging in Koha -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org