Fix UTF-8 handling of log files

This commit is contained in:
Eelco Dolstra 2014-08-13 18:53:29 +02:00
parent a2b27c7cf2
commit 42b23133e8
4 changed files with 9 additions and 7 deletions

View file

@ -12,6 +12,7 @@ use Data::Dump qw(dump);
use Nix::Store;
use Nix::Config;
use List::MoreUtils qw(all);
use Encode;
sub buildChain :Chained('/') :PathPart('build') :CaptureArgs(1) {
@ -141,9 +142,9 @@ sub showLog {
# !!! quick hack
my $pipeline = ($logPath =~ /.bz2$/ ? "bzip2 -d < $logPath" : "cat $logPath")
. " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -"
. " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " - | tail -n +2";
. " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " -";
$c->stash->{template} = 'log.tt';
$c->stash->{logtext} = `ulimit -t 5 ; $pipeline`;
$c->stash->{logtext} = decode("utf-8", `ulimit -t 5 ; $pipeline`);
}
elsif ($mode eq "raw") {

View file

@ -8,6 +8,7 @@ use Config::General;
use Hydra::Helper::CatalystUtils;
use Hydra::Model::DB;
use Nix::Store;
use Encode;
our @ISA = qw(Exporter);
our @EXPORT = qw(
@ -310,7 +311,7 @@ sub logContents {
else {
$cmd = defined $tail ? "tail -$tail $logPath" : "cat $logPath";
}
return `$cmd`;
return decode("utf-8", `$cmd`);
}

View file

@ -2,9 +2,7 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' encoding="UTF-8"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:output method='html' encoding="UTF-8" omit-xml-declaration="yes" />
<xsl:template match="logfile">
<p>

View file

@ -2,6 +2,8 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='xml' encoding="UTF-8" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
@ -23,5 +25,5 @@
<xsl:apply-templates select="@*|node()"/>
</line>
</xsl:template>
</xsl:stylesheet>