From fe376c7d8531279a1b6c0ebb9b0a2ed671b43a00 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 11 Jun 2021 15:12:32 +0000 Subject: [PATCH] Bug 28555: Improve logging for overdue_notices.pl Currenlty the output with -v from overdue_notices is a bit overwhelming and hard to parse I do a few things here: 1 - Only show SQL if verbose > 1 2 - Add some separators to make it more readab;e 3 - Remove some redundant messages with branchcode and borrowernumber To test: 1: perl misc/cronjobs/overdue_notices.pl -v 2: Notice you get a LOT of information all smushed together 3: Apply patch 4: perl misc/cronjobs/overdue_notices.pl -v 5: Less info, and easier to read 6: perl misc/cronjobs/overdue_notices.pl -v -v 7: All the info, but nicer to read Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- misc/cronjobs/overdue_notices.pl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 3eca0337df..3a58d1196b 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -470,6 +470,7 @@ foreach my $branchcode (@branches) { || $library->inbound_email_address; my @output_chunks; # may be sent to mail or stdout or csv file. + $verbose and print "======================================\n"; $verbose and warn sprintf "branchcode : '%s' using %s\n", $branchcode, $branch_email_address; my $sql2 = <<"END_SQL"; @@ -524,9 +525,10 @@ END_SQL next unless defined $mindays; if ( !$overdue_rules->{"letter$i"} ) { - $verbose and warn "No letter$i code for branch '$branchcode'"; + $verbose and warn sprintf "No letter code found for pass %s\n", $i; next PERIOD; } + $verbose and warn sprintf "Using letter code '%s' for pass %s\n", $overdue_rules->{"letter$i"}, $i; # $letter->{'content'} is the text of the mail that is sent. # this text contains fields that are replaced by their value. Those fields must be written between brackets @@ -562,7 +564,12 @@ END_SQL my $sth = $dbh->prepare($borrower_sql); $sth->execute(@borrower_parameters); - $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays, ". $date_to_run->datetime() .")\nreturns " . $sth->rows . " rows"; + if ( $verbose > 1 ){ + warn sprintf "--------Borrower SQL------\n"; + warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays, ". $date_to_run->datetime() .")\n"; + warn sprintf "--------------------------\n"; + } + $verbose and warn sprintf "Found %s borrowers with overdues\n", $sth->rows; my $borrowernumber; while ( my $data = $sth->fetchrow_hashref ) { @@ -602,8 +609,7 @@ END_SQL $data->{'firstname'} && $data->{'surname'} ? ', ' : '', $data->{'firstname'} || '', $borrowernumber ); - $verbose - and warn "borrower $borr has items triggering level $i."; + $verbose and warn "borrower $borr has items triggering level $i.\n"; my $patron = Koha::Patrons->find( $borrowernumber ); @emails_to_use = (); @@ -649,7 +655,6 @@ END_SQL $verbose and warn "debarring $borr\n"; } my @params = ($borrowernumber,$branchcode); - $verbose and warn "STH2 PARAMS: borrowernumber = $borrowernumber"; $sth2->execute(@params); my $itemcount = 0; -- 2.39.5