Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Show exception stack traces in Log Viewer #86

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Lumper.UI/Views/LogViewer/LogViewerView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
tsa96 marked this conversation as resolved.
Show resolved Hide resolved
Logs.Inlines.Add(
new Run(indent + ex.StackTrace.Replace("\n", "\n" + indent)) { Foreground = Brushes.Tomato }
);
}
}

if (StateService.Instance.LogAutoScroll)
Expand Down