From a1955f2a56710a22d19376e4a8e5a7bf3e794deb Mon Sep 17 00:00:00 2001 From: Tobias Tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:55:47 +0100 Subject: [PATCH] Write error logs to stderr (#7003) --- .../src/CommandLine/Commands/ComposeCommand.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/HotChocolate/Fusion/src/CommandLine/Commands/ComposeCommand.cs b/src/HotChocolate/Fusion/src/CommandLine/Commands/ComposeCommand.cs index 2c0fd8ca965..9a5f2d9cd1f 100644 --- a/src/HotChocolate/Fusion/src/CommandLine/Commands/ComposeCommand.cs +++ b/src/HotChocolate/Fusion/src/CommandLine/Commands/ComposeCommand.cs @@ -1,4 +1,5 @@ using System.CommandLine; +using System.CommandLine.IO; using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; @@ -293,17 +294,23 @@ public void Write(LogEntry e) HasErrors = true; } + var writer = console.Out; + if (e.Severity == LogSeverity.Error) + { + writer = console.Error; + } + if (e.Code is null) { - console.WriteLine($"{e.Severity}: {e.Message}"); + writer.WriteLine($"{e.Severity}: {e.Message}"); } else if (e.Coordinate is null) { - console.WriteLine($"{e.Severity}: {e.Code} {e.Message}"); + writer.WriteLine($"{e.Severity}: {e.Code} {e.Message}"); } else { - console.WriteLine($"{e.Severity}: {e.Code} {e.Message} {e.Coordinate}"); + writer.WriteLine($"{e.Severity}: {e.Code} {e.Message} {e.Coordinate}"); } } }