# -w and --disable-error can't go together
if ($error_only && $disable_error) {
- die "FATAL: please choose between no error report and reporting errors only.\n";
+ die "FATAL: please choose between no event report and reporting events only.\n";
}
# Set default search pattern for database and user name in log_line_prefix
-u | --dbuser username : only report what concern the given user
-v | --verbose : enable verbose or debug mode. Disabled by default.
-V | --version : show pgBadger version and exit.
- -w | --watch-mode : only report errors just like logwatch could do.
+ -w | --watch-mode : only report events/errors just like logwatch could do.
-x | --extension : output format. Values: text or html. Default: html
-z | --zcat exec_path : set the full path to the zcat program. Use it if
zcat is not on your path or you want to use gzcat.
my $fmt_errors = &comma_numbers($overall_stat{'errors_number'}) || 0;
my $fmt_unique_error = &comma_numbers(scalar keys %{$overall_stat{'unique_normalized_errors'}}) || 0;
print $fh qq{
-Number of errors: $fmt_errors
-Number of unique normalized errors: $fmt_unique_error
+Number of events: $fmt_errors
+Number of unique normalized events: $fmt_unique_error
};
}
if ($tempfile_info{count}) {
sub show_error_as_text
{
- print $fh "\n- Most frequent errors (N) ---------------------------------------------\n\n";
+ print $fh "\n- Most frequent events (N) ---------------------------------------------\n\n";
my $idx = 1;
foreach my $k (sort {$error_info{$b}{count} <=> $error_info{$a}{count}} keys %error_info) {
next if (!$error_info{$k}{count});
last if ($idx > $top);
if ($error_info{$k}{count} > 1) {
- print $fh "$idx) " . &comma_numbers($error_info{$k}{count}) . " - $k\n";
+ my $msg = $k;
+ $msg =~ s/HINT: (parameter "[^"]+" changed to)/LOG: $1/;
+ print $fh "$idx) " . &comma_numbers($error_info{$k}{count}) . " - $msg\n";
print $fh "--\n";
my $j = 1;
for (my $i = 0 ; $i <= $#{$error_info{$k}{date}} ; $i++) {
+ if ($error_info{$k}{error}[$i] =~ s/HINT: (parameter "[^"]+" changed to)/LOG: $1/) {
+ $logs_type{HINT}--;
+ $logs_type{LOG}++;
+ }
print $fh "\t- Example $j: $error_info{$k}{date}[$i] - $error_info{$k}{error}[$i]\n";
print $fh "\t\tDetail: $error_info{$k}{detail}[$i]\n" if ($error_info{$k}{detail}[$i]);
print $fh "\t\tContext: $error_info{$k}{context}[$i]\n" if ($error_info{$k}{context}[$i]);
}
print $fh "Logs type Count Percentage\n";
foreach my $d (sort keys %logs_type) {
+ next if (!$logs_type{$d});
print $fh "$d\t\t", &comma_numbers($logs_type{$d}), "\t", sprintf("%0.2f", ($logs_type{$d} * 100) / $total_logs), "%\n";
}
}
}
}
if (!$disable_error) {
- print $fh qq{<a href="#NormalizedErrorsMostFrequentReport">Most frequent errors (N)</a> | };
+ print $fh qq{<a href="#NormalizedErrorsMostFrequentReport">Most frequent events (N)</a> | };
print $fh qq{<a href="#LogsTypeReport">Logs per type</a>};
}
print $fh "</div>\n";
}
}
if (!$disable_error) {
- print $fh "<li><a href=\"#NormalizedErrorsMostFrequentReport\">Most frequent errors (N)</a></li>\n";
+ print $fh "<li><a href=\"#NormalizedErrorsMostFrequentReport\">Most frequent events (N)</a></li>\n";
print $fh qq{<li><a href="#LogsTypeReport">Logs per type</a></li>\n};
}
print $fh qq{</ul>
my $fmt_errors = &comma_numbers($overall_stat{'errors_number'}) || 0;
my $fmt_unique_error = &comma_numbers(scalar keys %{$overall_stat{'unique_normalized_errors'}}) || 0;
print $fh qq{
-<li>Number of errors: $fmt_errors</li>
-<li>Number of unique normalized errors: $fmt_unique_error</li>
+<li>Number of events: $fmt_errors</li>
+<li>Number of unique normalized events: $fmt_unique_error</li>
</ul>
</td><td valign="top">
<ul>
<div class="information">
<table><tr><td valign="top">
<ul>
-<li>Number of errors: $fmt_errors</li>
-<li>Number of unique normalized errors: $fmt_unique_error</li>
+<li>Number of events: $fmt_errors</li>
+<li>Number of unique normalized events: $fmt_unique_error</li>
</ul>
</td></tr></table>
</div>
sub show_error_as_html
{
print $fh qq{
-<h2 id="NormalizedErrorsMostFrequentReport">Most frequent errors (N) <a href="#top" title="Back to top">^</a></h2>
+<h2 id="NormalizedErrorsMostFrequentReport">Most frequent events (N) <a href="#top" title="Back to top">^</a></h2>
<table class="queryList">
<tr>
<th>Rank</th>
}
print $fh "</table></div></div></td>\n";
if ($error_info{$k}{count} > 1) {
- print $fh "<td><div class=\"error\">$k</div>";
+ my $msg = $k;
+ $msg =~ s/HINT: (parameter "[^"]+" changed to)/LOG: $1/;
+ print $fh "<td><div class=\"error\">$msg</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++) {
+ if ($error_info{$k}{error}[$i] =~ s/HINT: (parameter "[^"]+" changed to)/LOG: $1/) {
+ $logs_type{HINT}--;
+ $logs_type{LOG}++;
+ }
my $c = $i % 2;
print $fh "<div class=\"example$c\" title=\"$error_info{$k}{date}[$i]\">$error_info{$k}{error}[$i]</div>\n";
print $fh "<div class=\"errorInformation$c\">Detail: $error_info{$k}{detail}[$i]</div>\n"
my $c = 0;
foreach my $d (sort keys %logs_type) {
+ next if (!$logs_type{$d});
my $colb = $c % 2;
print $fh "<tr class=\"row$colb\"><td>$d</td><td class=\"right\">", &comma_numbers($logs_type{$d}),
"</td><td class=\"right\">", sprintf("%0.2f", ($logs_type{$d} * 100) / $total_logs), "%</td></tr>\n";
return;
}
+ # Force parameter change to be a hint message so that it can appear
+ # in the event/error/warning messages report part.
+ if (($t_loglevel eq 'LOG') && ($t_query =~ /parameter "[^"]+" changed to "[^"]+"/)) {
+ $t_loglevel = 'HINT';
+ }
+
# Do not parse lines that are not an error like message
if ($error_only && ($t_loglevel !~ /(WARNING|ERROR|FATAL|PANIC|DETAIL|HINT|STATEMENT|CONTEXT)/)) {
if (exists $cur_info{$t_pid} && ($t_session != $cur_info{$t_pid}{session})) {