Skip to content

Commit

Permalink
Write error logs to stderr (#7003)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-tengler authored Mar 20, 2024
1 parent 4afef84 commit a1955f2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/HotChocolate/Fusion/src/CommandLine/Commands/ComposeCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.CommandLine;
using System.CommandLine.IO;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -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}");
}
}
}
Expand Down

0 comments on commit a1955f2

Please sign in to comment.