diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b3928d..ecbc1d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
0.7.3 (Next)
============
+* [#202](https://github.com/jenkinsci/ansicolor-plugin/pull/202): Render logs correctly for long running jobs which generate lots of output - [@tszmytka](https://github.com/tszmytka).
* Your contribution here.
diff --git a/pom.xml b/pom.xml
index f8848ee..6caa6b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,6 +93,18 @@
3.16.1
test
+
+ org.awaitility
+ awaitility
+ 4.0.3
+ test
+
+
+ org.hamcrest
+ hamcrest
+
+
+
diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiColorBuildWrapper.java b/src/main/java/hudson/plugins/ansicolor/AnsiColorBuildWrapper.java
index d478a1f..af4babd 100644
--- a/src/main/java/hudson/plugins/ansicolor/AnsiColorBuildWrapper.java
+++ b/src/main/java/hudson/plugins/ansicolor/AnsiColorBuildWrapper.java
@@ -64,6 +64,7 @@ public final class AnsiColorBuildWrapper extends SimpleBuildWrapper implements S
/**
* Create a new {@link AnsiColorBuildWrapper}.
+ * @param colorMapName Name of the color map to use
*/
@DataBoundConstructor
public AnsiColorBuildWrapper(String colorMapName) {
diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java
index 4e48859..3a81241 100644
--- a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java
+++ b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java
@@ -24,7 +24,7 @@ public final class AnsiColorConsoleLogFilter extends ConsoleLogFilter implements
private static final long serialVersionUID = 1L;
- private static final Logger LOG = Logger.getLogger(AnsiColorConsoleLogFilter.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(AnsiColorConsoleLogFilter.class.getName());
private AnsiColorMap colorMap;
private final Map notes;
@@ -46,14 +46,14 @@ public AnsiColorConsoleLogFilter(AnsiColorMap colorMap) {
pregenerateNote(AnsiAttributeElement.framed());
pregenerateNote(AnsiAttributeElement.overline());
// TODO other cases, and other methods
- LOG.log(Level.FINE, "Notes pregenerated for {0}", notes.keySet());
+ LOGGER.log(Level.FINE, "Notes pregenerated for {0}", notes.keySet());
}
-
+
private void pregenerateNote(AnsiAttributeElement element) {
element.emitOpen(html -> pregenerateNote(html));
element.emitClose(html -> pregenerateNote(html));
}
-
+
private void pregenerateNote(String html) {
if (!notes.containsKey(html)) {
JenkinsJVM.checkJenkinsJVM();
@@ -91,7 +91,7 @@ public void emitHtml(@Nonnull String html) {
new SimpleHtmlNote(html).encodeTo(logger);
}
} catch (IOException e) {
- LOG.log(Level.WARNING, "Failed to add HTML markup '" + html + "'", e);
+ LOGGER.log(Level.WARNING, "Failed to add HTML markup '" + html + "'", e);
}
}
});
diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiColorStep.java b/src/main/java/hudson/plugins/ansicolor/AnsiColorStep.java
index fb53bd5..75eb537 100644
--- a/src/main/java/hudson/plugins/ansicolor/AnsiColorStep.java
+++ b/src/main/java/hudson/plugins/ansicolor/AnsiColorStep.java
@@ -72,6 +72,7 @@ private static class ExecutionImpl extends AbstractStepExecutionImpl {
@Override
public boolean start() throws Exception {
StepContext context = getContext();
+
EnvironmentExpander currentEnvironment = context.get(EnvironmentExpander.class);
EnvironmentExpander terminalEnvironment = EnvironmentExpander.constant(Collections.singletonMap("TERM", colorMapName));
context.newBodyInvoker()
@@ -157,6 +158,12 @@ private void issueAction(StepContext context, ColorizedAction action) {
run.addAction(action);
taskListener.annotate(new ActionNote(action));
ensureRendering(taskListener);
+ final ColorizedAction currentAction = new ColorizedAction(action.getColorMapName(), ColorizedAction.Command.CURRENT);
+ if (action.getCommand().equals(ColorizedAction.Command.START)) {
+ run.addAction(currentAction);
+ } else {
+ run.removeAction(currentAction);
+ }
}
} catch (IOException | InterruptedException e) {
LOGGER.log(Level.WARNING, "Could not annotate. Ansicolor plugin will not work correctly.", e);
diff --git a/src/main/java/hudson/plugins/ansicolor/ColorConsoleAnnotator.java b/src/main/java/hudson/plugins/ansicolor/ColorConsoleAnnotator.java
index aaf7b9a..133a4a6 100644
--- a/src/main/java/hudson/plugins/ansicolor/ColorConsoleAnnotator.java
+++ b/src/main/java/hudson/plugins/ansicolor/ColorConsoleAnnotator.java
@@ -88,6 +88,7 @@ public ConsoleAnnotator