Skip to content

Commit

Permalink
Added CapturingOutputStream for convenience
Browse files Browse the repository at this point in the history
Marked logging to file as deprecated for ExecOutputStream
  • Loading branch information
Quesar committed Jul 14, 2021
1 parent 4defd03 commit 02f9263
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.14.4.1-SNAPSHOT
version=0.14.5.0-SNAPSHOT
13 changes: 13 additions & 0 deletions src/main/java/lv/ctco/scm/utils/exec/CapturingOutputStream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package lv.ctco.scm.utils.exec;

public class CapturingOutputStream extends ExecOutputStream {

public CapturingOutputStream() {
this.setOutputFilter(new FullOutputFilter());
}

public CapturingOutputStream(ExecOutputFilter filter) {
this.setOutputFilter(filter);
}

}
24 changes: 18 additions & 6 deletions src/main/java/lv/ctco/scm/utils/exec/ExecOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,35 @@
import java.util.ArrayList;
import java.util.List;

public final class ExecOutputStream extends LogOutputStream {
public class ExecOutputStream extends LogOutputStream {

private final Logger logger = LoggerFactory.getLogger(getClass());
private Logger logger;

private ExecOutputFilter outputFilter;
private ExecOutputFilter loggerFilter;
private ExecOutputFilter outputFilter = new NullOutputFilter();
private ExecOutputFilter loggerFilter = new NullOutputFilter();

@Deprecated
private ExecOutputFilter fileFilter = new NullOutputFilter();

private List<String> output = new ArrayList<>();

@Deprecated
private File logFile;

public ExecOutputStream() {
this.outputFilter = new NullOutputFilter();
this.loggerFilter = new NullOutputFilter();
this.logger = LoggerFactory.getLogger(getClass());
}

public ExecOutputStream(ExecOutputFilter outputFilter, ExecOutputFilter loggerFilter) {
this.logger = LoggerFactory.getLogger(getClass());
this.outputFilter = outputFilter;
this.loggerFilter = loggerFilter;
}

public void setLogger(Logger logger) {
this.logger = logger;
}

public ExecOutputFilter getOutputFilter() {
return outputFilter;
}
Expand All @@ -55,10 +63,12 @@ public void setLoggerFilter(ExecOutputFilter loggerFilter) {
this.loggerFilter = loggerFilter;
}

@Deprecated
public ExecOutputFilter getFileFilter() {
return fileFilter;
}

@Deprecated
public void setFileFilter(ExecOutputFilter fileFilter) {
this.fileFilter = fileFilter;
}
Expand All @@ -67,10 +77,12 @@ public List<String> getOutput() {
return output;
}

@Deprecated
public File getLogFile() {
return logFile;
}

@Deprecated
public void setLogFile(File logFile) throws IOException {
if (logFile == null) {
this.logFile = null;
Expand Down

0 comments on commit 02f9263

Please sign in to comment.