* Option to show the tail of a log.

This commit is contained in:
Eelco Dolstra 2009-03-16 12:16:33 +00:00
parent 54475b9266
commit a6e84d8431
4 changed files with 17 additions and 4 deletions

View file

@ -65,7 +65,7 @@ sub showLog {
notFound($c, "Log file $path no longer exists.") unless -f $path; notFound($c, "Log file $path no longer exists.") unless -f $path;
if ($mode eq "") { if (!$mode) {
# !!! quick hack # !!! quick hack
my $pipeline = ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path") my $pipeline = ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path")
. " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -" . " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -"
@ -79,6 +79,11 @@ sub showLog {
$c->serve_static_file($path); $c->serve_static_file($path);
} }
elsif ($mode eq "tail") {
$c->stash->{'plain'} = { data => scalar `tail -n 50 $path` };
$c->forward('Hydra::View::Plain');
}
else { else {
error($c, "Unknown log display mode `$mode'."); error($c, "Unknown log display mode `$mode'.");
} }

View file

@ -0,0 +1,7 @@
package Hydra::View::Plain;
use strict;
use warnings;
use base 'Catalyst::View::Download::Plain';
1;

View file

@ -163,7 +163,8 @@
<th>Logfile:</th> <th>Logfile:</th>
<td> <td>
<a href="[% c.uri_for('/build' build.id 'log') %]"><strong>Available</strong></a> <a href="[% c.uri_for('/build' build.id 'log') %]"><strong>Available</strong></a>
(<a href="[% c.uri_for('/build' build.id 'log' 'raw') %]">raw</a>) (<a href="[% c.uri_for('/build' build.id 'log' 'raw') %]">raw</a>,
<a href="[% c.uri_for('/build' build.id 'log' 'tail') %]">tail</a>)
</td> </td>
</tr> </tr>
[% END %] [% END %]
@ -274,7 +275,7 @@
<span class="error">Failed: [% HTML.escape(step.errormsg) %]</span> <span class="error">Failed: [% HTML.escape(step.errormsg) %]</span>
[% END %] [% END %]
[% IF step.logfile %] [% IF step.logfile %]
(<a href="[% log %]">log</a>, <a href="[% "$log/raw" %]">raw</a>) (<a href="[% log %]">log</a>, <a href="[% "$log/raw" %]">raw</a>, <a href="[% "$log/tail" %]">tail</a>)
[% END %] [% END %]
</td> </td>
</tr> </tr>

View file

@ -368,7 +368,7 @@ sub checkJobSet {
# Store the errors messages for jobs that failed to evaluate. # Store the errors messages for jobs that failed to evaluate.
my $msg = ""; my $msg = "";
foreach my $error (@{$jobs->{error}}) { foreach my $error (@{$jobs->{error}}) {
$msg .= "at `" . $error->{location} . "': " . $error->{msg} . "\n"; $msg .= "at `" . $error->{location} . "': " . $error->{msg} . "\n\n";
} }
setJobsetError($jobset, $msg); setJobsetError($jobset, $msg);
} }