Skip to content

Commit a7f04c9

Browse files
committed
Log combined messages
1 parent c2579eb commit a7f04c9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Kitodo-Command/src/main/java/org/kitodo/command/Command.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import java.util.Collections;
1818
import java.util.List;
1919
import java.util.Scanner;
20+
import java.util.stream.Collectors;
21+
import java.util.stream.Stream;
2022

2123
import org.apache.logging.log4j.LogManager;
2224
import org.apache.logging.log4j.Logger;
@@ -47,15 +49,17 @@ public CommandResult runCommand(String command) {
4749
InputStream errorInputStream = process.getErrorStream()) {
4850
List<String> outputMessage = inputStreamArrayToList(inputStream);
4951
List<String> errorMessage = inputStreamArrayToList(errorInputStream);
52+
List<String> combinedMessages = Stream.concat(outputMessage.stream(), errorMessage.stream())
53+
.collect(Collectors.toList());
5054
int errCode = process.waitFor();
5155
if (Integer.valueOf(errCode).equals(0)) {
5256
commandResult = new CommandResult(command, true, outputMessage);
5357
logger.info("Execution of Command {} was successful!: {}",
54-
commandResult.getCommand(), commandResult.getMessages());
58+
commandResult.getCommand(), combinedMessages);
5559
} else {
5660
commandResult = new CommandResult(command, false, errorMessage);
5761
logger.error("Execution of Command {} failed!: {}",
58-
commandResult.getCommand(), commandResult.getMessages());
62+
commandResult.getCommand(), combinedMessages);
5963
}
6064
}
6165
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)