Skip to content

Commit

Permalink
Fix detection of new log entries in remote files through ssh. Thanks …
Browse files Browse the repository at this point in the history
…to Luca Ferrari for the report
  • Loading branch information
gilles-migops committed Mar 26, 2022
1 parent 3b03a6c commit 6a4750b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions pgbadger
Expand Up @@ -4980,7 +4980,9 @@ sub check_file_changed
# Incremental mode is not possible for the moment with http download
return 1 if ($file =~ /^(http[s]*:|[s]*ftp:)/);

my $lfile = &get_log_file($file, $totalsize);
my $ssh_download = ($file =~ /^ssh:/i) ? 1 : 0;

my $lfile = &get_log_file($file, $totalsize, $remote_host || $ssh_download);
return if (!defined $lfile);

# Compressed files do not allow seeking
Expand Down Expand Up @@ -17752,7 +17754,7 @@ sub autodetect_format
elsif (!$http_download && !$log_command && !$journalctl_cmd)
{
# try to detect syslogs, stderr, csv, jsonlog or pgbouncer format
my $tfile = &get_log_file($file, $totalsize, $remote_host);
my $tfile = &get_log_file($file, $totalsize, $remote_host || $ssh_download);
if (defined $tfile)
{
while (my $line = <$tfile>)
Expand Down Expand Up @@ -17964,7 +17966,7 @@ sub progress_bar

return if (!$progress);

my ($package, $filename, $line) = caller;
#my ($package, $filename, $line) = caller;
$width ||= 25;
$char ||= '=';

Expand Down
2 changes: 1 addition & 1 deletion t/02_basics.t
Expand Up @@ -41,7 +41,7 @@ ok( $? == 0 && $ret > 0, "Light log from STDIN");
$ret = `perl pgbadger -q --outdir '.' -o $TEXT -o $JSON -o - -x json $LOG > t/ret.json`;
my $ret2 = `stat --printf='%s' t/ret.json $TEXT $JSON`;
chomp($ret);
ok( $? == 0 && $ret2 eq '13478015985134780', "Multiple output format '$ret2' = '13478015985134780'");
ok( $? == 0 && $ret2 eq '13511215985135112', "Multiple output format '$ret2' = '13511215985135112'");

$ret = `perl pgbadger -q -o - $SYSLOG`;
ok( $? == 0 && (length($ret) >= 24060), "syslog report to stdout");
Expand Down

0 comments on commit 6a4750b

Please sign in to comment.