From e6091dc13e8fab2acf9e2959f364692878a1ce96 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 3 Jun 2026 16:35:10 +0100 Subject: [PATCH] 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 Signed-off-by: Nick Clemens Signed-off-by: Pedro Amorim --- C4/Log.pm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/C4/Log.pm b/C4/Log.pm index d41ae51803..723dcdda40 100644 --- a/C4/Log.pm +++ b/C4/Log.pm @@ -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. Only logs when the +C 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__