]> granicus.if.org Git - pgbadger/commitdiff
Remove usage of Storable::file_magic to autodetect binary format file, it is not...
authorDarold Gilles <gilles@darold.net>
Thu, 14 Feb 2013 11:19:17 +0000 (12:19 +0100)
committerDarold Gilles <gilles@darold.net>
Thu, 14 Feb 2013 11:19:17 +0000 (12:19 +0100)
pgbadger

index 55921a1bac3df7cdcb8c0148ef1fb47efe563c64..fed433057245c3a437fcb8fbf5d9008e3f30103e 100755 (executable)
--- 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 = <TESTFILE>;
+       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(