The dump_logfile now returns the whole log file if the limit
parameter is set to 0. This must be done explicitly though, as in the
case of 'limit' being undefined, the default as before, 50 will be
used.
Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
return ($count, $lines);
}
- $start = 0 if !$start;
- $limit = 50 if !$limit;
+ $start = $start // 0;
+ $limit = $limit // 50;
+ my $read_until_end = ($limit == 0) ? 1 : 0;
my $line;
if ($filter) {
while (defined($line = <$fh>)) {
next if $line !~ m/$filter/;
next if $count++ < $start;
- next if $limit <= 0;
+ if (!$read_until_end) {
+ next if $limit <= 0;
+ $limit--;
+ }
chomp $line;
push @$lines, { n => $count, t => $line};
- $limit--;
}
} else {
while (defined($line = <$fh>)) {
next if $count++ < $start;
- next if $limit <= 0;
+ if (!$read_until_end) {
+ next if $limit <= 0;
+ $limit--;
+ }
chomp $line;
push @$lines, { n => $count, t => $line};
- $limit--;
}
}