From: Gilles Darold Date: Tue, 10 Sep 2019 04:47:43 +0000 (+0200) Subject: Fix option -f | --format that was not applied on all files get from the parameter... X-Git-Tag: v11.1~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f32ee6f2b203f1715ec54501ece9132fdf49373a;p=pgbadger Fix option -f | --format that was not applied on all files get from the parameter list where log format auto-detection was failing, the format was taken from the fist file parsed. Thanks to Levente Birta for the report. --- diff --git a/pgbadger b/pgbadger index 6b97f29..4fd17ef 100755 --- a/pgbadger +++ b/pgbadger @@ -1382,7 +1382,9 @@ if ($incremental && !$remote_host) else { # Auto detect log format for proper parsing - my $fmt = autodetect_format($f, $file_size{$f}); + my $fmt = $format || 'stderr'; + $fmt = autodetect_format($f, $file_size{$f}); + $fmt ||= $format; # Set regex to parse the log file $fmt = set_parser_regex($fmt); @@ -15966,7 +15968,7 @@ sub autodetect_format $nfound++ if ($f); $fmt = $f; $ident_name{$i}++ if ($i); - last if (($nfound > 10) || ($nline > 5000)); + last if (($nfound >= 10) || ($nline > 5000)); } $tfile->close(); } @@ -16011,8 +16013,9 @@ sub autodetect_format } } } - else + elsif (!$fmt) { + # Force format if forced as parameter with -f $fmt = $format; }