Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
[FIXED JENKINS-27392] Handling ConsoleLogFilter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Mar 30, 2015
1 parent 05916af commit 38cd1ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -46,6 +46,7 @@ public abstract class BodyInvoker {
* <dl>
* <dt>{@link EnvVars}<dd>use {@link EnvironmentExpander} instead
* <dt>{@link EnvironmentExpander}<dd>use {@link EnvironmentExpander#merge}
* <dt>{@link ConsoleLogFilter}<dd>merge two instances if present; your implementation should expect {@code null} for the {@code build} parameter, and be {@link Serializable}
* </dl>
* @see StepContext#get(Class)
*
Expand Down
Expand Up @@ -26,6 +26,7 @@

import hudson.EnvVars;
import hudson.Launcher;
import hudson.console.ConsoleLogFilter;
import hudson.model.Computer;
import hudson.model.Job;
import hudson.model.Node;
Expand All @@ -34,6 +35,7 @@
import hudson.util.StreamTaskListener;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -88,8 +90,12 @@ public abstract class DefaultStepContext extends StepContext {
la = new LogActionImpl(getNode(), Charset.defaultCharset());
getNode().addAction(la);
}

listener = new StreamTaskListener(new FileOutputStream(la.getLogFile(), true));
ConsoleLogFilter filter = get(ConsoleLogFilter.class);
OutputStream os = new FileOutputStream(la.getLogFile(), true);
if (filter != null) {
os = filter.decorateLogger(null, os);
}
listener = new StreamTaskListener(os);
getExecution().addListener(new GraphListener() {
@Override public void onNewHead(FlowNode node) {
try {
Expand Down

0 comments on commit 38cd1ea

Please sign in to comment.