# Stores top N error sample queries
sub set_top_error_sample
{
- my ($q, $date, $detail) = @_;
+ my ($q, $date, $real_error, $detail) = @_;
- # always keep the last error messages
- if (exists $error_info{$q}{date} && ($#{$error_info{$q}{date}} >= $sample)) {
- shift(@{$error_info{$q}{date}});
- shift(@{$error_info{$q}{detail}});
+ # Stop when we have our number of samples
+ if (!exists $error_info{$q}{date} || ($#{$error_info{$q}{date}} < $sample)) {
+ if (!grep(/\Q$real_error\E/, @{$error_info{$q}{error}})) {
+ push(@{$error_info{$q}{date}}, $date);
+ push(@{$error_info{$q}{detail}}, $detail);
+ push(@{$error_info{$q}{error}}, $real_error);
+ }
}
- push(@{$error_info{$q}{date}}, $date);
- push(@{$error_info{$q}{detail}}, $detail);
}
$idx++;
}
print $fh "\n\n";
- print $fh "Report generated by <a href=\"https://github.com/dalibo/pgbadger\">PgBadger</a> $VERSION. License: GPL v3.\n";
+ print $fh "Report generated by <a href=\"https://github.com/dalibo/pgbadger\">PgBadger</a> $VERSION.\n";
}
{
print $fh qq{
<div class="footer">
- Report generated by <a href="https://github.com/dalibo/pgbadger">PgBadger</a> $VERSION. License: GPL v3.
+ Report generated by <a href="https://github.com/dalibo/pgbadger">PgBadger</a> $VERSION.
</div>
</div>
<div id="littleToc">
print $fh "<td><div class=\"error\">$k</div>";
print $fh "<input type=\"button\" class=\"examplesButton\" id=\"button_NormalizedErrorsMostFrequentReport_$idx\" name=\"button_NormalizedErrorsMostFrequentReport_$idx\" value=\"Show examples\" onclick=\"javascript:toggle('button_NormalizedErrorsMostFrequentReport_$idx', 'examples_NormalizedErrorsMostFrequentReport_$idx', 'examples');\" /><div id=\"examples_NormalizedErrorsMostFrequentReport_$idx\" class=\"examples\" style=\"display:none;\">";
for (my $i = 0; $i <= $#{$error_info{$k}{date}}; $i++) {
- print $fh "<div class=\"example$i\" title=\"$error_info{$k}{date}[$i]\">$k</div>\n";
+ print $fh "<div class=\"example$i\" title=\"$error_info{$k}{date}[$i]\">$error_info{$k}{error}[$i]</div>\n";
print $fh "<div class=\"errorInformation\">Detail: $error_info{$k}{detail}[$i]</div>\n" if ($error_info{$k}{detail}[$i]);
}
print $fh "</div>";
# Store normalyzed query samples
my $cur_last_log_date = "$cur_info{year}-$cur_info{month}-$cur_info{day} $cur_info{hour}:$cur_info{min}:$cur_info{sec}";
if ($t_loglevel =~ /DETAIL|STATEMENT/) {
- &set_top_error_sample($normalized_error, $cur_last_log_date, $t_query);
+ &set_top_error_sample($normalized_error, $cur_last_log_date, $cur_info{query}, $t_query);
} else {
- &set_top_error_sample($normalized_error, $cur_last_log_date);
+ &set_top_error_sample($normalized_error, $cur_last_log_date, $cur_info{query});
}
%cur_info = ();
return;