From 33422a36fcb076e029097643edb23450dbdbc4b1 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 24 Jan 2023 08:19:05 +0100 Subject: [PATCH] Fix system out / err streams when redirecting to file (#779) --- .../mvnd/common/logging/TerminalOutput.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java b/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java index 85ad87d2a..56f89b56e 100644 --- a/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java +++ b/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java @@ -323,14 +323,22 @@ private boolean doAccept(Message entry) { } case Message.PRINT_OUT: { Message.StringMessage d = (Message.StringMessage) entry; - clearDisplay(); - System.out.printf("%s%n", d.getMessage()); + if (log instanceof FileLog) { + log.accept(d.getMessage()); + } else { + clearDisplay(); + System.out.printf("%s%n", d.getMessage()); + } break; } case Message.PRINT_ERR: { Message.StringMessage d = (Message.StringMessage) entry; - clearDisplay(); - System.err.printf("%s%n", d.getMessage()); + if (log instanceof FileLog) { + log.accept(d.getMessage()); + } else { + clearDisplay(); + System.err.printf("%s%n", d.getMessage()); + } break; } case Message.PROMPT: {