Bug 16312

Summary: Koha::Logger overload configuration for command line scripts verbosity levels
Product: Koha Reporter: Olli-Antti Kivilahti <olli-antti.kivilahti>
Component: Architecture, internals, and plumbingAssignee: Olli-Antti Kivilahti <olli-antti.kivilahti>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 16302, 16304, 14167, 16303    
Bug Blocks: 16313    
Attachments: Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels
Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels
Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels

Description Olli-Antti Kivilahti 2016-04-20 17:05:46 UTC
To be able to set the -v|--verbose flags from the command line and still use Koha::Logger, we must be able to overload/extend default appenders and log levels on a easy case-by-case basis directly from the Perl-code.

To deploy verbose mode in a commandline script, add the following code to your cronjob/script:

use C4::Context;
use Koha::Logger;
C4::Context->setCommandlineEnvironment();
Koha::Logger->setConsoleVerbosity( 1 || -3 || 'WARN' || ... );

See attached tests and perldoc for more info.
Comment 1 Olli-Antti Kivilahti 2016-04-20 17:09:14 UTC Comment hidden (obsolete)
Comment 2 Olli-Antti Kivilahti 2016-04-20 17:22:32 UTC Comment hidden (obsolete)
Comment 3 Olli-Antti Kivilahti 2016-04-21 07:40:54 UTC
Created attachment 50495 [details] [review]
Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels

To be able to set the -v|--verbose flags from the command line and still use
Koha::Logger, we must be able to overload/extend default appenders and log levels
on a easy case-by-case basis directly from the Perl-code.

To deploy verbose mode in a commandline script, add the following code to your
cronjob/script:

use C4::Context;
use Koha::Logger;
C4::Context->setCommandlineEnvironment();
Koha::Logger->setConsoleVerbosity( 1 || -3 || 'WARN' || ... );

The module using the Koha::Logger must lazyLoad the module/package-level logger
using Koha::Logger->new(), so the overloads can be deployed.

See attached tests and perldoc for more info.