From d58b8a9db93e9488931eedbec5cbaf9fc792b655 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 21 Apr 2021 16:45:12 -0400 Subject: [PATCH] feat: IcdConsole traces to Visual Studio output --- ICD.Common.Utils/AnsiUtils.cs | 10 ++++++++++ ICD.Common.Utils/IcdConsole.cs | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ICD.Common.Utils/AnsiUtils.cs b/ICD.Common.Utils/AnsiUtils.cs index a59f2a1..11e62ae 100644 --- a/ICD.Common.Utils/AnsiUtils.cs +++ b/ICD.Common.Utils/AnsiUtils.cs @@ -81,6 +81,16 @@ namespace ICD.Common.Utils #endif } + /// + /// Removes ANSI control sequences from the string. + /// + /// + /// + public static string StripAnsi(string data) + { + return Regex.Replace(data, ANSI_REGEX, string.Empty); + } + /// /// Prefixes the given data with an ANSI control sequence and suffixes with a reset sequence. /// diff --git a/ICD.Common.Utils/IcdConsole.cs b/ICD.Common.Utils/IcdConsole.cs index 1edbc2b..7bb8362 100644 --- a/ICD.Common.Utils/IcdConsole.cs +++ b/ICD.Common.Utils/IcdConsole.cs @@ -91,6 +91,7 @@ namespace ICD.Common.Utils if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server) CrestronConsole.PrintLine(fixedMessage); #else + Trace.WriteLine(AnsiUtils.StripAnsi(fixedMessage)); Console.WriteLine(fixedMessage); #endif } @@ -132,7 +133,8 @@ namespace ICD.Common.Utils if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server) CrestronConsole.Print(fixedMessage); #else - Console.Write(message); + Trace.Write(AnsiUtils.StripAnsi(fixedMessage)); + Console.Write(fixedMessage); #endif } finally