Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions lib/pause_2017/PAUSE/Web/Controller/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,18 @@ sub tail_logfile {
my $pause = $c->stash(".pause");
my $req = $c->req;

my $tail = $req->param("pause99_tail_logfile_1") || 5000;
my $file = $PAUSE::Config->{PAUSE_LOG};
if ($PAUSE::Config->{TESTHOST}) {
$file = "/usr/local/apache/logs/error_log"; # for testing
my $lines = $req->param("pause99_tail_logfile_1") || 1000;

my @valid_options = qw(500 1000 10000 20000);
unless (grep {; $lines eq $_ } @valid_options) {
$lines = 500;
}
open my $fh, "<", $file or die "Could not open $file: $!";
seek $fh, -$tail, 2;
local($/);
$/ = "\n";
<$fh>;
$/ = undef;

$pause->{tail} = <$fh>;

my $logs = readpipe("/usr/bin/journalctl --lines $lines --identifier paused");

$logs = qq{Error reading PAUSE daemon logs!\n} if $? != 0;

$pause->{tail} = $logs;
}

sub change_passwd {
Expand Down
4 changes: 2 additions & 2 deletions lib/pause_2017/templates/user/tail_logfile.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
% my $pause = stash(".pause") || {};

<div id="logs">
<%= select_field pause99_tail_logfile_1 => [qw/2000 5000 10000 20000 40000/]; =%>
<input type="submit" name="pause99_tail_logfile_sub" value="Tail characters">
<%= select_field pause99_tail_logfile_1 => [qw/500 1000 10000 20000/]; =%>
<input type="submit" name="pause99_tail_logfile_sub" value="Tail lines">
<input class="search" placeholder="Filter">
<table class="table compact">
<tbody class="list">
Expand Down
11 changes: 1 addition & 10 deletions t/pause_2017/action/tail_logfile.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,12 @@ use Test::PAUSE::Web;
use utf8;

my $default = {
pause99_tail_logfile_1 => 5000,
pause99_tail_logfile_1 => 500,
pause99_tail_logfile_sub => 1,
};

Test::PAUSE::Web->setup;

{
open my $fh, '>', $PAUSE::Config->{PAUSE_LOG};
say $fh <<LOG;
pause log
pause log
pause log
LOG
}

subtest 'get' => sub {
for my $test (Test::PAUSE::Web->tests_for('user')) {
my ($path, $user) = @$test;
Expand Down