Bug 42766: Add logscriptaction() to C4::Log

Adds a logscriptaction() function parallel to cronlogaction() that logs
to the SCRIPTS action-log module rather than CRONJOBS, gated behind the
new ScriptLog system preference. Exported from C4::Log alongside the
existing cronlogaction().

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-06-03 16:35:10 +01:00 committed by Pedro Amorim
parent 57cceec6bc
commit e6091dc13e
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 22 additions and 1 deletions

View File

@ -38,7 +38,7 @@ use vars qw(@ISA @EXPORT);
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(logaction cronlogaction);
@EXPORT = qw(logaction cronlogaction logscriptaction);
}
=head1 NAME
@ -229,6 +229,27 @@ sub cronlogaction {
logaction( 'CRONJOBS', $action, $$, $loginfo ) if C4::Context->preference('CronjobLog');
}
=item logscriptaction
&logscriptaction({ info => $info, action => $action });
Convenience routine to add a record into the action_logs table for a
non-cron Koha script. Logs the path of the running script plus any
additional information provided in C<info>. Only logs when the
C<ScriptLog> system preference is enabled.
=cut
sub logscriptaction {
my $params = shift;
my $info = $params->{info};
my $action = $params->{action};
$action ||= "Run";
my $loginfo = $0;
$loginfo .= ' ' . $info if $info;
logaction( 'SCRIPTS', $action, $$, $loginfo ) if C4::Context->preference('ScriptLog');
}
1;
__END__