From: Darold Gilles Date: Tue, 24 Jul 2012 09:22:31 +0000 (+0200) Subject: Change regex on log parser to allow missing ending space in log_line_prefix. This... X-Git-Tag: v3.2~181 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c8e91d07bab2238a8a3b159680e95cf2b1a74fe;p=pgbadger Change regex on log parser to allow missing ending space in log_line_prefix. This seems a common mistake. --- diff --git a/pgbadger b/pgbadger index 961d777..26cf60f 100755 --- a/pgbadger +++ b/pgbadger @@ -419,7 +419,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+(.*)/) + /^(...)\s+(\d+)\s(\d+):(\d+):(\d+)\s([^\s]+)\s([^\[]+)\[(\d+)\]:\s\[([0-9\-]+)\]\s*([^:]*?)\s*([A-Z]+?):\s+(.*)/) { # skip non postgresql lines @@ -443,7 +443,7 @@ foreach $logfile (@log_files) { # Process the log line &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+(.*)/) { + } elsif ($line =~ /^(...)\s+(\d+)\s(\d+):(\d+):(\d+)\s([^\s]+)\s([^\[]+)\[(\d+)\]:\s\[([0-9\-]+)\]\s*(.*)/) { $cur_pid = $8; my $t_query = $10; @@ -478,7 +478,7 @@ foreach $logfile (@log_files) { } elsif ($format eq 'stderr') { # Parse stderr lines - if ($line =~ /(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)\s([^\s]+)\s\[(\d+)\]:\s\[([0-9\-]+)\]\s*(.*?)\s+([A-Z]+):\s+(.*)/) { + if ($line =~ /(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)\s([^\s]+)\s\[(\d+)\]:\s\[([0-9\-]+)\]\s*([^:]*?)\s*([A-Z]+?):\s+(.*)/) { # Skip unwanted lines my $cur_date = "$1$2$3$4$5$6"; @@ -3361,13 +3361,13 @@ sub autodetect_format $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+$duration/) { $fmt = 'syslog'; $nfound++; $ident_name{$1}++; # Is stderr lines - } elsif ($line =~ /\d+-\d+-\d+\s\d+:\d+:\d+\s[^\s]+\s\[\d+\]:\s\[[0-9\-]+\]\s.*:\s+$duration/) { + } elsif ($line =~ /\d+-\d+-\d+\s\d+:\d+:\d+\s[^\s]+\s\[\d+\]:\s\[[0-9\-]+\][^:]+:\s+$duration/) { $fmt = 'stderr'; $nfound++; } elsif ($line =~ tr/,/,/ >= 12) {