use of ch.ivyteam.ivy.maven.util.stream.LineOrientedOutputStreamRedirector in project project-build-plugin by axonivy.
the class EngineControl method createEngineLogStreamForwarder.
private PumpStreamHandler createEngineLogStreamForwarder(Consumer<String> logLineHandler) throws FileNotFoundException {
OutputStream output = getEngineLogTarget();
OutputStream engineLogStream = new LineOrientedOutputStreamRedirector(output) {
@Override
protected void processLine(byte[] b) throws IOException {
// write file log
super.processLine(b);
String line = new String(b);
context.log.debug("engine: " + line);
if (logLineHandler != null) {
logLineHandler.accept(line);
}
}
};
PumpStreamHandler streamHandler = new PumpStreamHandler(engineLogStream, System.err) {
@Override
public void stop() throws IOException {
super.stop();
// we opened the stream - we're responsible to close it!
engineLogStream.close();
}
};
return streamHandler;
}
Aggregations