You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2023/01/24 16:54:29 UTC

[maven-mvnd] 02/05: Fix system out / err streams when redirecting to file (#779)

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch mvnd-0.9.x
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git

commit 33422a36fcb076e029097643edb23450dbdbc4b1
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Jan 24 08:19:05 2023 +0100

    Fix system out / err streams when redirecting to file (#779)
---
 .../mvndaemon/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 85ad87d2..56f89b56 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 @@ public class TerminalOutput implements ClientOutput {
             }
             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: {