From ade14c7d19da54fcfe706227c961701ecc040724 Mon Sep 17 00:00:00 2001 From: tsa96 Date: Tue, 28 Jan 2025 14:53:01 +0000 Subject: [PATCH] refactor(ui): show exception stack traces in logviewer --- .../Views/LogViewer/LogViewerView.axaml.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Lumper.UI/Views/LogViewer/LogViewerView.axaml.cs b/src/Lumper.UI/Views/LogViewer/LogViewerView.axaml.cs index a870269e..9c431262 100644 --- a/src/Lumper.UI/Views/LogViewer/LogViewerView.axaml.cs +++ b/src/Lumper.UI/Views/LogViewer/LogViewerView.axaml.cs @@ -89,11 +89,16 @@ private void AddLogMessage(LogMessage logMessage) { FontStyle = FontStyle.Italic, FontWeight = FontWeight.Medium, - Foreground = Brushes.Gray, + Foreground = Brushes.LightGray, } ); - Logs.Inlines.Add(new Run(logMessage.Message)); + Logs.Inlines.Add( + new Run(logMessage.Message) + { + Foreground = logMessage.Exception is null ? Brushes.White : Brushes.LightPink, + } + ); if (logMessage.Exception is { } ex) { @@ -107,6 +112,14 @@ private void AddLogMessage(LogMessage logMessage) ); Logs.Inlines.Add(new Run(ex.Message) { Foreground = Brushes.IndianRed }); + if (ex.StackTrace is not null) + { + Logs.Inlines.Add(new LineBreak()); + string indent = new(' ', 8 + 26); + Logs.Inlines.Add( + new Run(indent + ex.StackTrace.Replace("\n", "\n" + indent)) { Foreground = Brushes.Tomato } + ); + } } if (StateService.Instance.LogAutoScroll)