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.
Created attachment 50471 [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.
Created attachment 50472 [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.
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.