Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels
Summary: Koha::Logger overload configuration for command line scripts verbosity levels
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Olli-Antti Kivilahti
QA Contact: Testopia
URL:
Keywords:
Depends on: 16302 16304 14167 16303
Blocks: 16313
  Show dependency treegraph
 
Reported: 2016-04-20 17:05 UTC by Olli-Antti Kivilahti
Modified: 2016-04-21 07:40 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels (12.42 KB, patch)
2016-04-20 17:09 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels (13.23 KB, patch)
2016-04-20 17:22 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 16312 - Koha::Logger overload configuration for command line scripts verbosity levels (12.84 KB, patch)
2016-04-21 07:40 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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.