remove ascii escapes from log in tail page and emails

This commit is contained in:
Rob Vermaas 2011-06-10 09:53:15 +00:00
parent 259d163ec9
commit 48b435c2de
3 changed files with 8 additions and 3 deletions

View file

@ -55,7 +55,7 @@ sub view_build : Chained('build') PathPart('') Args(0) {
(my $lastBuildStep) = $build->buildsteps->search({},{order_by => "stepnr DESC", rows => 1}); (my $lastBuildStep) = $build->buildsteps->search({},{order_by => "stepnr DESC", rows => 1});
my $path = defined $lastBuildStep ? $lastBuildStep->logfile : "" ; my $path = defined $lastBuildStep ? $lastBuildStep->logfile : "" ;
if (defined $build->resultInfo && ($build->resultInfo->buildstatus == 1 || $build->resultInfo->buildstatus == 6) && !($path eq "") && -f $lastBuildStep->logfile) { if (defined $build->resultInfo && ($build->resultInfo->buildstatus == 1 || $build->resultInfo->buildstatus == 6) && !($path eq "") && -f $lastBuildStep->logfile) {
$c->stash->{logtext} = `tail -n 50 $path`; $c->stash->{logtext} = removeAsciiEscapes(`tail -n 50 $path`);
} }
if($build->finished) { if($build->finished) {

View file

@ -14,7 +14,7 @@ our @EXPORT = qw(
registerRoot getGCRootsDir gcRootFor registerRoot getGCRootsDir gcRootFor
getPrimaryBuildsForView getPrimaryBuildsForView
getPrimaryBuildTotal getPrimaryBuildTotal
getViewResult getLatestSuccessfulViewResult jobsetOverview); getViewResult getLatestSuccessfulViewResult jobsetOverview removeAsciiEscapes);
sub isValidPath { sub isValidPath {
@ -259,5 +259,10 @@ sub getLatestSuccessfulViewResult {
return undef; return undef;
} }
sub removeAsciiEscapes {
my ($logtext) = @_;
$logtext =~ s/\e\[[A-Za-z]//g;
return $logtext;
}
1; 1;

View file

@ -156,7 +156,7 @@ sub sendEmailNotification {
my $loglines = 50; my $loglines = 50;
my $logfile = $build->resultInfo->logfile; my $logfile = $build->resultInfo->logfile;
my $logtext = defined $logfile && -e $logfile ? `tail -$loglines $logfile` : "No logfile available.\n"; my $logtext = defined $logfile && -e $logfile ? removeAsciiEscapes(`tail -$loglines $logfile`) : "No logfile available.\n";
my $body = "Hi,\n" my $body = "Hi,\n"
. "\n" . "\n"