diff --git a/contrib/cirrus/logformatter b/contrib/cirrus/logformatter
index 1dc6187689..6f88866ee8 100755
--- a/contrib/cirrus/logformatter
+++ b/contrib/cirrus/logformatter
@@ -251,6 +251,19 @@ END_HTML
$previous_timestamp = $timestamp;
}
+ # Helper function for printing a formatted line. This should always
+ # be followed by 'next LINE'.
+ my $print_line = sub {
+ my $css = shift;
+
+ print { $out_fh } "$timestamp"
+ if $timestamp;
+ print { $out_fh } "" if $css;
+ print { $out_fh } $line;
+ print { $out_fh } "" if $css;
+ print { $out_fh } "\n";
+ };
+
# Try to identify the git commit we're working with...
if ($line =~ m!/define.gitCommit=([0-9a-f]+)!) {
$git_commit = $1;
@@ -305,9 +318,7 @@ END_HTML
if ($line =~ /^\s*(OK|FAILED)\s+\(/) {
undef $looks_like_python;
my $css = ($1 eq 'OK' ? 'passed' : 'failed');
- print { $out_fh } "$timestamp"
- if $timestamp;
- print { $out_fh } "", $line, "\n";
+ $print_line->("bats-$css");
next LINE;
}
}
@@ -339,14 +350,11 @@ END_HTML
push @{$bats_count{__fail_list}}, [ $2, $3 ] if $1;
}
- $line = "$line";
-
$bats_count{$css}++;
+ $css = "bats-$css";
}
- print { $out_fh } "$timestamp"
- if $timestamp;
- print { $out_fh } $line, "\n";
+ $print_line->($css);
next LINE;
}
elsif ($looks_like_python) {
@@ -362,13 +370,10 @@ END_HTML
}
if ($css) {
- $line = "$line";
-
$bats_count{$css}++;
+ $css = "bats-$css";
}
- print { $out_fh } "$timestamp"
- if $timestamp;
- print { $out_fh } $line, "\n";
+ $print_line->($css);
next LINE;
}