From e27dec353e5953bf97626daa3d1e50ca3cf551f5 Mon Sep 17 00:00:00 2001 From: Lordfirespeed <28568841+Lordfirespeed@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:14:58 +0000 Subject: [PATCH] get ansi formatted content when implemented --- .../Extensions/LogEventArgsExtensions.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/AvaloniaBepInExConsole.Server/Extensions/LogEventArgsExtensions.cs b/AvaloniaBepInExConsole.Server/Extensions/LogEventArgsExtensions.cs index d0c2b46..f674aed 100644 --- a/AvaloniaBepInExConsole.Server/Extensions/LogEventArgsExtensions.cs +++ b/AvaloniaBepInExConsole.Server/Extensions/LogEventArgsExtensions.cs @@ -7,8 +7,17 @@ public static class LogEventArgsExtensions { public static LogEvent ToAvaloniaBepInExConsoleLogEvent(this LogEventArgs logEventArgs) => new LogEvent() { - Content = logEventArgs.ToString(), + Content = logEventArgs.GetContent(), Level = logEventArgs.Level.ToAvaloniaBepInExConsoleLogLevel(), SourceName = logEventArgs.Source.SourceName, }; + + private static string GetContent(this LogEventArgs logEventArgs) + { + if (logEventArgs is IAnsiFormattable ansiFormattable) { + return ansiFormattable.ToAnsiFormattedString(); + } + + return logEventArgs.ToString(); + } }