forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more sophisticated output forwarding from exec tasks
Fixes elastic#8583
- Loading branch information
1 parent
c8d704c
commit 87dc146
Showing
4 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
group = 'org.logstash' | ||
|
||
apply plugin: 'java' |
29 changes: 29 additions & 0 deletions
29
buildSrc/src/main/java/org/logstash/gradle/ExecLogOutputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.logstash.gradle; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.PrintStream; | ||
|
||
/** | ||
* Stream that can be used to forward Gradle Exec task output to an arbitrary {@link PrintStream}. | ||
*/ | ||
public final class ExecLogOutputStream extends ByteArrayOutputStream { | ||
|
||
/** | ||
* Underlying {@link PrintStream} to flush output to. | ||
*/ | ||
private final PrintStream stream; | ||
|
||
/** | ||
* Ctor. | ||
* @param stream PrintStream to flush to | ||
*/ | ||
public ExecLogOutputStream(final PrintStream stream) { | ||
this.stream = stream; | ||
} | ||
|
||
@Override | ||
public synchronized void flush() { | ||
stream.print(toString()); | ||
reset(); | ||
} | ||
} |