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:
parent
57cceec6bc
commit
e6091dc13e
23
C4/Log.pm
23
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<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__
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue