From: Darold Gilles Date: Wed, 26 Sep 2012 19:25:27 +0000 (+0200) Subject: Fix issue with compressed csvlog. Thanks to Philip Freeman for the report. X-Git-Tag: v3.2~139 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90ce363d4f20058e65eea5df0eff3c8b16610a98;p=pgbadger Fix issue with compressed csvlog. Thanks to Philip Freeman for the report. --- diff --git a/doc/pgBadger.pod b/doc/pgBadger.pod index 179cd73..739f46a 100644 --- a/doc/pgBadger.pod +++ b/doc/pgBadger.pod @@ -14,7 +14,6 @@ Arguments: returning a list of file. If you want to pass log content from stdin use - as filename. Note that input from stdin will not work with csvlog. - Options: -a | --average minutes : number of minutes to build the average graphs of diff --git a/pgbadger b/pgbadger index ff88631..aebac08 100755 --- a/pgbadger +++ b/pgbadger @@ -454,7 +454,14 @@ foreach my $logfile (@log_files) { if ($format eq 'csv') { require Text::CSV; my $csv = Text::CSV->new({binary => 1, eol => $/}); - open(my $io, "<", $logfile) or die "FATAL: cannot read csvlog file $logfile. $!\n"; + my $io = undef; + if ($logfile !~ /\.gz/) { + open($io, "<", $logfile) or die "FATAL: cannot read csvlog file $logfile. $!\n"; + } else { + open($io, "$zcat $logfile |") or die "FATAL: cannot open pipe to $zcat $logfile. $!\n"; + # Real size of the file is unknow + $totalsize = 0; + } # Parse csvlog lines my $getout = 0;