Bug 42714: Add automatic cronlogaction logging to Koha::Script
Add INIT and END blocks to Koha::Script that automatically call
cronlogaction on script start (with command line options) and
completion. This removes the need for scripts to manually handle
cron log entries.
This will mean that any script importing Koha::Script will be logged,
but I think the addition is beneficial.
To test:
1 - Ensure CronjobLog is enabled
2 - perl misc/cronjobs/fines.pl --test
3 - Confirm start and end are logged in action logs:
http://localhost:8081/cgi-bin/koha/tools/viewlog.pl?src=&user=&modules=CRONJOBS&actions=&object=&info=&interfaces=&from=&to=&output=screen&basename=Export&report_name=&do_it=1
4 - Apply patch
5 - Repeat 2
6 - Reload the logs, confirm the new logs look the same
7 - Sign off
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
47a09c9182
commit
ecd056b21d
|
|
@ -39,9 +39,28 @@ use File::Basename qw( fileparse );
|
|||
use Fcntl qw( LOCK_EX LOCK_NB );
|
||||
|
||||
use C4::Context;
|
||||
use C4::Log qw( cronlogaction );
|
||||
use Koha::Exceptions;
|
||||
use Koha::Exception;
|
||||
|
||||
INIT {
|
||||
my $command_line_options = join( " ", @ARGV );
|
||||
cronlogaction( { info => $command_line_options } );
|
||||
}
|
||||
|
||||
END {
|
||||
cronlogaction( { action => 'End', info => "COMPLETED" } );
|
||||
}
|
||||
|
||||
=head2 import
|
||||
|
||||
use Koha::Script;
|
||||
use Koha::Script -cron;
|
||||
|
||||
Sets the interface and userenv appropriately based on the flags passed.
|
||||
|
||||
=cut
|
||||
|
||||
sub import {
|
||||
my $class = shift;
|
||||
my @flags = @_;
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ my $log;
|
|||
my $maxdays;
|
||||
my $verify_issue;
|
||||
|
||||
my $command_line_options = join( " ", @ARGV );
|
||||
cronlogaction( { info => $command_line_options } );
|
||||
|
||||
GetOptions(
|
||||
'h|help' => \$help,
|
||||
|
|
@ -212,8 +210,6 @@ Number of Overdue Items:
|
|||
EOM
|
||||
}
|
||||
|
||||
cronlogaction( { action => 'End', info => "COMPLETED" } );
|
||||
|
||||
sub set_holiday {
|
||||
my ( $branch, $dt ) = @_;
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,6 @@ if ( not $result or $want_help ) {
|
|||
usage();
|
||||
}
|
||||
|
||||
cronlogaction( { info => $command_line_options } );
|
||||
|
||||
my $linker_module = "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' );
|
||||
unless ( can_load( modules => { $linker_module => undef } ) ) {
|
||||
$linker_module = 'C4::Linker::Default';
|
||||
|
|
|
|||
Loading…
Reference in New Issue