* Provide access to the raw, non-pretty-printed logfiles.

Unfortunately necessary for large logs.
This commit is contained in:
Eelco Dolstra 2009-03-14 23:27:08 +00:00
parent 4404800ad8
commit eeddf5752d
4 changed files with 32 additions and 24 deletions

View file

@ -39,43 +39,49 @@ sub view_build : Chained('build') PathPart('') Args(0) {
} }
sub view_nixlog : Chained('build') PathPart('nixlog') Args(1) { sub view_nixlog : Chained('build') PathPart('nixlog') {
my ($self, $c, $stepnr) = @_; my ($self, $c, $stepnr, $mode) = @_;
my $step = $c->stash->{build}->buildsteps->find({stepnr => $stepnr}); my $step = $c->stash->{build}->buildsteps->find({stepnr => $stepnr});
notFound($c, "Build doesn't have a build step $stepnr.") if !defined $step; notFound($c, "Build doesn't have a build step $stepnr.") if !defined $step;
$c->stash->{template} = 'log.tt';
$c->stash->{step} = $step; $c->stash->{step} = $step;
# !!! should be done in the view (as a TT plugin). showLog($c, $step->logfile, $mode);
$c->stash->{logtext} = loadLog($c, $step->logfile);
} }
sub view_log : Chained('build') PathPart('log') Args(0) { sub view_log : Chained('build') PathPart('log') {
my ($self, $c) = @_; my ($self, $c, $mode) = @_;
error($c, "Build didn't produce a log.") if !defined $c->stash->{build}->resultInfo->logfile; error($c, "Build didn't produce a log.") if !defined $c->stash->{build}->resultInfo->logfile;
$c->stash->{template} = 'log.tt'; showLog($c, $c->stash->{build}->resultInfo->logfile, $mode);
# !!! should be done in the view (as a TT plugin).
$c->stash->{logtext} = loadLog($c, $c->stash->{build}->resultInfo->logfile);
} }
sub loadLog { sub showLog {
my ($c, $path) = @_; my ($c, $path, $mode) = @_;
notFound($c, "Log file $path no longer exists.") unless -f $path; notFound($c, "Log file $path no longer exists.") unless -f $path;
# !!! quick hack if ($mode eq "") {
my $pipeline = ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path") # !!! quick hack
. " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -" my $pipeline = ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path")
. " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " - | tail -n +2"; . " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -"
. " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " - | tail -n +2";
return `$pipeline`; $c->stash->{template} = 'log.tt';
$c->stash->{logtext} = `$pipeline`;
}
elsif ($mode eq "raw") {
$c->serve_static_file($path);
}
else {
error($c, "Unknown log display mode `$mode'.");
}
} }

View file

@ -163,6 +163,7 @@
<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>)
</td> </td>
</tr> </tr>
[% END %] [% END %]
@ -249,7 +250,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 %]">log</a>, <a href="[% "$log/raw" %]">raw</a>)
[% END %] [% END %]
</td> </td>
</tr> </tr>

View file

@ -33,14 +33,12 @@
[% BLOCK renderFullJobName %] [% BLOCK renderFullJobName %]
<tt> <tt>
[% INCLUDE renderProjectName %]:[% INCLUDE renderJobsetName %]:[% INCLUDE renderJobName %] [% INCLUDE renderProjectName %]:[% INCLUDE renderJobsetName %]:[% INCLUDE renderJobName %]
</a> </tt>
[% END %] [% END %]
[% BLOCK renderFullJobNameOfBuild %] [% BLOCK renderFullJobNameOfBuild %]
<tt>
[% INCLUDE renderFullJobName project=build.get_column("project") jobset = build.get_column("jobset") job = build.get_column("job") %] [% INCLUDE renderFullJobName project=build.get_column("project") jobset = build.get_column("jobset") job = build.get_column("job") %]
</a>
[% END %] [% END %]

View file

@ -1,6 +1,9 @@
[% WRAPPER layout.tt title="Logfile" %] [% WRAPPER layout.tt title="Logfile" %]
[% PROCESS common.tt %]
<h1>Logfile for <tt>[% build.project.name %]:[% build.job %]</tt> build [% build.id %][%IF step %], step [% step.stepnr %] (<tt>[% step.outpath %]</tt>)[% END %]</h1> <h1>Logfile for [% INCLUDE renderFullJobNameOfBuild %] build [% build.id %][%IF step %] step [% step.stepnr %][% END %]</h1>
<p>Below is the logfile of the <a href="[% c.uri_for('/build' build.id) %]">build</a> producing Nix store path <tt>[% step.outpath %]</tt>.</p>
<div class="buildlog"> <div class="buildlog">
[% logtext -%] [% logtext -%]