31 lines
521 B
Perl
31 lines
521 B
Perl
|
package Hydra::View::NixLog;
|
||
|
|
||
|
use strict;
|
||
|
use base qw/Catalyst::View/;
|
||
|
use Hydra::Helper::CatalystUtils;
|
||
|
|
||
|
sub process {
|
||
|
my ($self, $c) = @_;
|
||
|
|
||
|
my $logPath = $c->stash->{logPath};
|
||
|
|
||
|
$c->response->content_type('text/plain');
|
||
|
|
||
|
my $fh = new IO::Handle;
|
||
|
|
||
|
if ($logPath =~ /\.bz2$/) {
|
||
|
open $fh, "bzip2 -dc < '$logPath' |" or die;
|
||
|
} else {
|
||
|
open $fh, "<$logPath" or die;
|
||
|
}
|
||
|
binmode($fh);
|
||
|
|
||
|
setCacheHeaders($c, 365 * 24 * 60 * 60);
|
||
|
|
||
|
$c->response->body($fh);
|
||
|
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
1;
|