+ # 1024 is a practical cutoff for the size distribution of our log files.
+ if ($use_compression) {
+ open($fh, "-|", "/usr/bin/gzip", "-c", "$filename")
+ or die "Could not create compressed file stream for file '$filename' - $!\n";
+ } else {
+ open($fh, '<', $filename) or die "Could not open file '$filename' - $!\n";
+ }
+
+ return {
+ download => {
+ fh => $fh,
+ stream => 1,
+ 'content-encoding' => $use_compression ? 'gzip' : undef,
+ 'content-type' => "text/plain",
+ 'content-disposition' => "attachment; filename=\"".$param->{upid}."\"",
+ },
+ },
+ } else {
+ my $start = $param->{start} // 0;
+ my $limit = $param->{limit} // 50;
+
+ my ($count, $lines) = PVE::Tools::dump_logfile($filename, $start, $limit);
+
+ $rpcenv->set_result_attrib('total', $count);
+
+ return $lines;
+ }