From ba9e0068e265cd68b804914acdaf43e159629e34 Mon Sep 17 00:00:00 2001 From: Gilles Darold Date: Thu, 18 Aug 2016 15:46:32 +0200 Subject: [PATCH] Fix parsing of remote file that was failing when the file does not exists locally. Thanks to clomdd for the report. --- pgbadger | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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); -- 2.50.1