From: Darold Gilles Date: Thu, 14 Feb 2013 11:19:17 +0000 (+0100) Subject: Remove usage of Storable::file_magic to autodetect binary format file, it is not... X-Git-Tag: v3.2~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56ca70d579c3e93117e8ce70094bb3dfe80b8bcf;p=pgbadger Remove usage of Storable::file_magic to autodetect binary format file, it is not include in core perl 5.8. Thanks to Marc Cousin for the report. --- diff --git a/pgbadger b/pgbadger index 55921a1..fed4330 100755 --- a/pgbadger +++ b/pgbadger @@ -940,8 +940,6 @@ sub multiprocess_progressbar my $cursize = 0; my $nqueries = 0; my $nerrors = 0; - #local $SIG{ALRM} = sub { warn "ALARM: no more data from pipe, stopping progress writer.\n"; exit(0); }; - #alarm $timeout; $pipe->reader(); while (my $r = <$pipe>) { chomp($r); @@ -952,9 +950,7 @@ sub multiprocess_progressbar $cursize = $totalsize if ($cursize > $totalsize); print STDERR &progress_bar($cursize, $totalsize, 25, '=', $nqueries, $nerrors); last if ($cursize >= $totalsize); - #alarm $timeout; } - #alarm 0; print STDERR "\n"; exit 0; @@ -1361,7 +1357,7 @@ sub process_file if (($stop_offset > 0) && ($format ne 'csv')) { print STDERR &progress_bar($cursize - $start_offset, $stop_offset, 25, '='); } else { - print STDERR &progress_bar($cursize, $totalsize, 25, '='); + print STDERR &progress_bar($cursize, $totalsize, 25, '=', $logfile); } print STDERR "\n"; } @@ -5155,8 +5151,12 @@ sub autodetect_format my $nline = 0; my $fmt = ''; + die "FATAL: can't open file $file, $!\n" unless(open(TESTFILE, $file)); + binmode(TESTFILE); + my $fltf = ; + close($fltf); # is file in binary format ? - if ( defined Storable::file_magic($file) ) { + if ( $fltf =~ /^pst\d/ ) { $fmt = 'binary'; } else { # try to detect syslogs or csv @@ -5261,7 +5261,7 @@ sub progress_bar my $file = $_[-1]; sprintf( "Loaded %d queries and %d events from binary file %s...\r", - ($queries || $overall_stat{'queries_number'}), ($errors || $overall_stat{'errors_number'}), $file + $overall_stat{'queries_number'}, $overall_stat{'errors_number'}, $queries ); } else { sprintf(