diff --git a/cli/src/main/java/com/devonfw/tools/ide/process/ProcessResultImpl.java b/cli/src/main/java/com/devonfw/tools/ide/process/ProcessResultImpl.java index 686c4bd18..fbb489667 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/process/ProcessResultImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/process/ProcessResultImpl.java @@ -3,7 +3,6 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import com.devonfw.tools.ide.cli.CliProcessException; import com.devonfw.tools.ide.context.IdeContext; @@ -72,7 +71,7 @@ public List getErr() { @Override public List getOutputMessages() { - return outputMessages; + return this.outputMessages; } @@ -85,18 +84,22 @@ public void log(IdeLogLevel level, IdeContext context) { public void log(IdeLogLevel outLevel, IdeContext context, IdeLogLevel errorLevel) { if (!this.outputMessages.isEmpty()) { - doLog(outLevel, getOutputMessages().stream().map(OutputMessage::message).collect(Collectors.toList()), context); + for (OutputMessage outputMessage : this.outputMessages) { + if (outputMessage.error()) { + doLog(errorLevel, outputMessage.message(), context); + } else { + doLog(outLevel, outputMessage.message(), context); + } + } } } - private void doLog(IdeLogLevel level, List lines, IdeContext context) { - for (String line : lines) { - // remove !MESSAGE from log message - if (line.startsWith("!MESSAGE ")) { - line = line.substring(9); - } - context.level(level).log(line); + private void doLog(IdeLogLevel level, String message, IdeContext context) { + // remove !MESSAGE from log message + if (message.startsWith("!MESSAGE ")) { + message = message.substring(9); } + context.level(level).log(message); } @Override