From 3fe7fa42e5fc3fdc1ad528be92e61e707ad9eb4d Mon Sep 17 00:00:00 2001 From: Matthias Heil Date: Tue, 10 Nov 2026 11:06:10 +0100 Subject: [PATCH] Alternate server exception log colors Use red and dark red alternation for server exceptions, green for other messages, and reorder the related using directives. --- PipeClient/Program.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/PipeClient/Program.cs b/PipeClient/Program.cs index b62cbe3..029fcd8 100644 --- a/PipeClient/Program.cs +++ b/PipeClient/Program.cs @@ -1,11 +1,12 @@ -using PipeShared; -using PipeMethodCalls; +using PipeMethodCalls; +using PipeShared; 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"); var report = new XElement("Report", new XAttribute("Started", DateTime.Now.ToString("O"))); +bool colorSwitch = false; Log("Client started."); @@ -52,12 +53,18 @@ lock (report) new XDocument(report).Save(reportPath); // Thread-safe: also called from the Process.Exited event + 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; + if (message.Contains("Server exception")) + { + Console.ForegroundColor = colorSwitch ? ConsoleColor.DarkRed : ConsoleColor.Red; + colorSwitch = !colorSwitch; + } + else + Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(message); Console.ResetColor(); }