This commit is contained in:
44
Elwig/Windows/LogWindow.xaml.cs
Normal file
44
Elwig/Windows/LogWindow.xaml.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Elwig.Helpers;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public partial class LogWindow : Window {
|
||||
|
||||
public LogWindow() {
|
||||
InitializeComponent();
|
||||
WindowState = WindowState.Maximized;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
||||
var log = Utils.GetLogEntries();
|
||||
EventList.ItemsSource = log
|
||||
.Select(e => new {
|
||||
Event = e,
|
||||
Lines = e.Message.Split('\n').ToArray(),
|
||||
})
|
||||
.Select(e => new {
|
||||
e.Event,
|
||||
Exception = e.Lines.FirstOrDefault(l => l.StartsWith("Exception Info: "))?[16..].Trim().Split(':', 2),
|
||||
Location = e.Lines.FirstOrDefault(l => l.StartsWith(" at Elwig."))?[5..].Trim(),
|
||||
})
|
||||
.Select(e => new {
|
||||
e.Event,
|
||||
e.Exception,
|
||||
ExceptionName = e.Exception?[0].Trim(),
|
||||
ExceptionMessage = e.Exception?.Length >= 2 ? e.Exception?[1].Trim() : null,
|
||||
e.Location,
|
||||
})
|
||||
.OrderByDescending(e => e.Event.TimeGenerated)
|
||||
.ToList();
|
||||
EventList.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void EventList_SelectionChanged(object sender, RoutedEventArgs evt) {
|
||||
var t = EventList.SelectedItem.GetType();
|
||||
var p = t.GetProperty("Event")!;
|
||||
EventData.Text = ((EventLogEntry)p.GetValue(EventList.SelectedItem)!).Message;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user