From: Gilles Darold Date: Thu, 18 Aug 2016 13:46:32 +0000 (+0200) Subject: Fix parsing of remote file that was failing when the file does not exists locally... X-Git-Tag: v8.3~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba9e0068e265cd68b804914acdaf43e159629e34;p=pgbadger Fix parsing of remote file that was failing when the file does not exists locally. Thanks to clomdd for the report. --- diff --git a/pgbadger b/pgbadger index 0819f62..b7a2733 100755 --- a/pgbadger +++ b/pgbadger @@ -1391,7 +1391,12 @@ if ( ($#given_log_files >= 0) && (($queue_size > 1) || ($job_per_file > 1)) ) { } # Get log format of the current file - my $fmt = &autodetect_format($logfile); + my $fmt = $format || 'stderr'; + if (!$remote_host && !$journalctl_cmd) { + $fmt = &autodetect_format($logfile); + } else { + &logmsg('DEBUG', "Can not autodetect log format, assuming $fmt."); + } # Set regex to parse the log file set_parser_regex($fmt); @@ -1470,7 +1475,12 @@ if ( ($#given_log_files >= 0) && (($queue_size > 1) || ($job_per_file > 1)) ) { foreach my $logfile ( @given_log_files ) { # Get log format of the current file - my $fmt = autodetect_format($logfile); + my $fmt = $format || 'stderr'; + if (!$remote_host && !$journalctl_cmd) { + $fmt = &autodetect_format($logfile); + } else { + &logmsg('DEBUG', "Can not autodetect log format, assuming $fmt."); + } # Set regex to parse the log file set_parser_regex($fmt);