Bug 35479: Log start, end, and any failures for each plugin's nightly cronjob

When running the plugins_nightly.pl cronjob, we should record the plugins that have a nightly method, logging the start and end of each plugins routine

Test Plan:
1) Enable CronjobLog
2) Install a plugin with a nightly cronjob ( e.g.
   https://github.com/bywatersolutions/koha-plugin-book-list-printer )
3) Run plugins_nightly.pl
4) Note new entries in the cronjob viewer for the start and end of the
   plugin's nightly cronjob run
5) Edit the plugin, add a line like "die 'this is a test';" to the
   plugin's nightly cronjob
6) Run plugins_nightly.pl
7) View the action logs, not the log for the error you added!

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit c4b777b056)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Kyle M Hall 2023-12-04 12:41:32 -05:00 committed by Fridolin Somers
parent 658ad821be
commit c0d2ee4c07
1 changed files with 4 additions and 0 deletions

View File

@ -22,10 +22,14 @@ if ( C4::Context->config("enable_plugins") ) {
);
foreach my $plugin (@plugins) {
my $plugin_name = ref $plugin;
try {
cronlogaction({ info => "running nightly cronjob for plugin $plugin_name" });
$plugin->cronjob_nightly();
cronlogaction({ info => "finished nightly cronjob for plugin $plugin_name" });
}
catch {
cronlogaction({ info => "failed to running nightly cronjob for plugin $plugin_name with error: $_" });
warn "$_";
$logger->warn("$_");
};