From c2af32cd0f1824fee883011fa0423197815bca73 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Sun, 16 Jun 2013 22:59:43 -0700 Subject: [PATCH] Fix Logger error spamming. --- bin/pt-agent | 8 +++++--- lib/Percona/Agent/Logger.pm | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/pt-agent b/bin/pt-agent index 6d225f75..860b7b5e 100755 --- a/bin/pt-agent +++ b/bin/pt-agent @@ -4971,13 +4971,15 @@ sub start_online_logging { ); }; if ( my $e = $EVAL_ERROR ) { - if ( ++$n_errors > 10 ) { - warn "$n_errors consecutive errors, no more error " - . "messages will be printed until log entries " + if ( $n_errors > 10 ) { + my $ts = ts(time, 1); # 1=UTC + warn "$ts WARNING $n_errors consecutive errors, no more " + . "error messages will be printed until log entries " . "are sent successfully again.\n"; } else { warn "Error sending log entry to API: $e"; + $n_errors++; } } else { diff --git a/lib/Percona/Agent/Logger.pm b/lib/Percona/Agent/Logger.pm index f17724ed..8ced4d37 100644 --- a/lib/Percona/Agent/Logger.pm +++ b/lib/Percona/Agent/Logger.pm @@ -183,13 +183,15 @@ sub start_online_logging { }; if ( my $e = $EVAL_ERROR ) { # Safegaurd: don't spam the agent log file with errors. - if ( ++$n_errors > 10 ) { - warn "$n_errors consecutive errors, no more error " - . "messages will be printed until log entries " + if ( $n_errors > 10 ) { + my $ts = ts(time, 1); # 1=UTC + warn "$ts WARNING $n_errors consecutive errors, no more " + . "error messages will be printed until log entries " . "are sent successfully again.\n"; } else { warn "Error sending log entry to API: $e"; + $n_errors++; } } else {