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(); }