Skip to content

Commit 9a2e2fc

Browse files
committed
tail_logfile: read from journalctl, not pause.log
This means we can stop writing pause.log! Also, this switches from "last n bytes" to "last n lines" and so adjusts the options a bit.
1 parent 8a61e9c commit 9a2e2fc

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

lib/pause_2017/PAUSE/Web/Controller/User.pm

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,18 @@ sub tail_logfile {
300300
my $pause = $c->stash(".pause");
301301
my $req = $c->req;
302302

303-
my $tail = $req->param("pause99_tail_logfile_1") || 5000;
304-
my $file = $PAUSE::Config->{PAUSE_LOG};
303+
my $lines = $req->param("pause99_tail_logfile_1") || 1000;
305304

306-
open my $fh, "<", $file or die "Could not open $file: $!";
307-
seek $fh, -$tail, 2;
308-
local($/);
309-
$/ = "\n";
310-
<$fh>;
311-
$/ = undef;
305+
my @valid_options = qw(500 1000 10000 20000);
306+
unless (grep {; $lines eq $_ } @valid_options) {
307+
$lines = 500;
308+
}
309+
310+
my $logs = readpipe("/usr/bin/journalctl --lines $lines --identifier paused");
311+
312+
$logs = qq{Error reading PAUSE daemon logs!\n} if $? != 0;
312313

313-
$pause->{tail} = <$fh>;
314+
$pause->{tail} = $logs;
314315
}
315316

316317
sub change_passwd {

lib/pause_2017/templates/user/tail_logfile.html.ep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
% my $pause = stash(".pause") || {};
33

44
<div id="logs">
5-
<%= select_field pause99_tail_logfile_1 => [qw/2000 5000 10000 20000 40000/]; =%>
6-
<input type="submit" name="pause99_tail_logfile_sub" value="Tail characters">
5+
<%= select_field pause99_tail_logfile_1 => [qw/500 1000 10000 20000/]; =%>
6+
<input type="submit" name="pause99_tail_logfile_sub" value="Tail lines">
77
<input class="search" placeholder="Filter">
88
<table class="table compact">
99
<tbody class="list">

0 commit comments

Comments
 (0)