]> granicus.if.org Git - pgbadger/commitdiff
Change fix on day with single digit to be formatted by sprintf()
authorDarold <gilles@darold.net>
Tue, 3 Jul 2012 20:59:13 +0000 (22:59 +0200)
committerDarold <gilles@darold.net>
Tue, 3 Jul 2012 20:59:13 +0000 (22:59 +0200)
pgbadger

index eb787b8542ea2b66b4285b2ab6d7d1caa7be4eae..707c839383ead41a7eb9c54de19947a2ffa5a977 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -393,19 +393,14 @@ foreach $logfile (@log_files) {
                                if ("$tmp_year$month_abbr{$1}$2" > $CURRENT_DATE) {
                                        $tmp_year = substr($CURRENT_DATE,1, 4) - 1;
                                }
-                               # Skip unwanted lines
                                # Fix single digit days
-                                my $day;
-                                if ($2 < 10) {
-                                        $day = "0$2";
-                                } else {
-                                        $day = $2;
-                                }
+                                my $day = sprintf("%02d", $2);
                                 my $cur_date = "$tmp_year$month_abbr{$1}$day$3$4$5";                           
+                               # Skip unwanted lines
                                next if ($from && ($from > $cur_date));
                                last if ($to && ($to < $cur_date));
                                # Process the log line
-                               &parse_query($tmp_year, $month_abbr{$1}, sprintf("%02d", $2), $3, $4, $5, $6, $8, $9, $10, $11,$12);
+                               &parse_query($tmp_year, $month_abbr{$1}, $day, $3, $4, $5, $6, $8, $9, $10, $11,$12);
                        } elsif ($line =~ /^(...)\s+(\d+)\s(\d+):(\d+):(\d+)\s([^\s]+)\s([^\[]+)\[(\d+)\]:\s\[([0-9\-]+)\]\s+[^\#]*(#011)[\t\s]*(.*)/) {
 
                                $cur_info{query} .= "\n" . $11;