From: Darold Gilles Date: Thu, 5 Jul 2012 07:52:19 +0000 (+0200) Subject: Fix autodetection of log format syslog with single-digit day number in date X-Git-Tag: v3.2~202 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f5179f692aa29f53f7036bc08b1346b578f4cdd;p=pgbadger Fix autodetection of log format syslog with single-digit day number in date --- diff --git a/pgbadger b/pgbadger index 247e7a0..2eb4e06 100755 --- a/pgbadger +++ b/pgbadger @@ -390,6 +390,7 @@ foreach $logfile (@log_files) { if ($format eq 'syslog') { if ($line =~ /^(...)\s+(\d+)\s(\d+):(\d+):(\d+)\s([^\s]+)\s([^\[]+)\[(\d+)\]:\s\[([0-9\-]+)\]\s*(.*?)\s+([A-Z]+:)\s+(.*)/) { + # skip non postgresql lines next if ($7 ne $ident); # Syslog do not have year information, so take care of year overlapping @@ -2435,6 +2436,7 @@ sub parse_query { my ($t_year, $t_month, $t_day, $t_hour, $t_min, $t_sec, $t_host, $t_pid, $t_session, $t_logprefix, $t_loglevel, $t_query) = @_; + # Get log level if ($t_loglevel !~ s/^.*(LOG|WARNING|ERROR|FATAL|PANIC|DETAIL|STATEMENT|HINT|CONTEXT):$/$1/) { # Unrecognized loglevel format @@ -2813,7 +2815,7 @@ sub autodetect_format next if (!$line); $nline++; # Is syslog lines ? - if ($line =~ /^...\s\d+\s\d+:\d+:\d+\s[^\s]+\s[^\[]+\[\d+\]:\s\[[0-9\-]+\]\s.*:\s+$duration/) { + if ($line =~ /^...\s+\d+\s\d+:\d+:\d+\s[^\s]+\s[^\[]+\[\d+\]:\s\[[0-9\-]+\]\s.*:\s+$duration/) { $fmt = 'syslog'; $nfound++; # Is stderr lines