]> granicus.if.org Git - pgbadger/commitdiff
Support timestamps for begin/end with fractional seconds (so it'll handle postgresql...
authorMarco Baringer <mb@bese.it>
Tue, 30 Jul 2013 14:39:53 +0000 (16:39 +0200)
committerMarco Baringer <mb@bese.it>
Tue, 30 Jul 2013 14:39:53 +0000 (16:39 +0200)
NB: This parses, but does not propertly handle, time zones.

pgbadger

index 7949b015c96dca3afa470ff57f10e74a16cdf65f..fdb43219b5f50be439fa1144f4499c8c9f28123c 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -506,14 +506,21 @@ sub check_regex
 
 # Check start/end date time
 if ($from) {
-       if ($from !~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {
-               die "FATAL: bad format for begin datetime, should be yyyy-mm-dd hh:mm:ss\n";
-       }
+       if ($from !~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})([.]\d+([+-]\d+)?)?$/) {
+               die "FATAL: bad format for begin datetime, should be yyyy-mm-dd hh:mm:ss.l+tz\n";
+       } else {
+                my $fractional_seconds = $7 || "0";
+                $from = "$1-$2-$3 $4:$5:$6.$7"
+        }
+
 }
 if ($to) {
-       if ($to !~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {
-               die "FATAL: bad format for ending datetime, should be yyyy-mm-dd hh:mm:ss\n";
-       }
+       if ($to !~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})([.]\d+([+-]\d+)?)?$/) {
+               die "FATAL: bad format for ending datetime, should be yyyy-mm-dd hh:mm:ss.l+tz\n";
+       } else {
+                my $fractional_seconds = $7 || "0";
+                $from = "$1-$2-$3 $4:$5:$6.$7"
+        }
 }
 
 # Stores the last parsed line from log file to allow incremental parsing