diff --git a/lib/pause_2017/PAUSE/Web/Controller/User.pm b/lib/pause_2017/PAUSE/Web/Controller/User.pm index d15ffede7..8ffcadd00 100644 --- a/lib/pause_2017/PAUSE/Web/Controller/User.pm +++ b/lib/pause_2017/PAUSE/Web/Controller/User.pm @@ -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 { diff --git a/lib/pause_2017/templates/user/tail_logfile.html.ep b/lib/pause_2017/templates/user/tail_logfile.html.ep index b7a469320..c67ceb344 100644 --- a/lib/pause_2017/templates/user/tail_logfile.html.ep +++ b/lib/pause_2017/templates/user/tail_logfile.html.ep @@ -2,8 +2,8 @@ % my $pause = stash(".pause") || {};
-<%= select_field pause99_tail_logfile_1 => [qw/2000 5000 10000 20000 40000/]; =%> - +<%= select_field pause99_tail_logfile_1 => [qw/500 1000 10000 20000/]; =%> + diff --git a/t/pause_2017/action/tail_logfile.t b/t/pause_2017/action/tail_logfile.t index 49bb91888..35c24a680 100644 --- a/t/pause_2017/action/tail_logfile.t +++ b/t/pause_2017/action/tail_logfile.t @@ -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 < sub { for my $test (Test::PAUSE::Web->tests_for('user')) { my ($path, $user) = @$test;