From 23c2a9ea1646d484457b8284c5ead6e37660fe2d Mon Sep 17 00:00:00 2001 From: Matthias Heil Date: Tue, 10 Nov 2026 10:38:20 +0100 Subject: [PATCH] Add colored console output to logging Update `Log` to write messages to the console, using red for server exceptions and blue for other messages. Preserve thread-safe XML report logging and reorder `using` directives. --- Client/Program.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Client/Program.cs b/Client/Program.cs index dde9fb2..fe5cb9d 100644 --- a/Client/Program.cs +++ b/Client/Program.cs @@ -1,7 +1,7 @@ -using System.Diagnostics; -using System.Xml.Linq; +using ClientServerShared; using PipeMethodCalls; -using ClientServerShared; +using System.Diagnostics; +using System.Xml.Linq; // All output is written to an XML report next to the executable string reportPath = Path.Combine(AppContext.BaseDirectory, "ClientReport.xml"); @@ -56,6 +56,10 @@ void Log(string message) { lock (report) report.Add(new XElement("Entry", new XAttribute("Time", DateTime.Now.ToString("O")), message)); + + Console.ForegroundColor = message.Contains("Server exception") ? ConsoleColor.Red : ConsoleColor.Blue; + Console.WriteLine(message); + Console.ResetColor(); } async Task BasicCallsExampleAsync()