Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Filter Logs in ModList intaller view #2677

Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Wabbajack.App.Wpf/Models/LogStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public interface ILogMessage
string ShortMessage { get; }
DateTime TimeStamp { get; }
string LongMessage { get; }
LogLevel Level { get; }
}

private record LogMessage(LogEventInfo info) : ILogMessage
Expand All @@ -76,6 +77,7 @@ private record LogMessage(LogEventInfo info) : ILogMessage
public string ShortMessage => info.FormattedMessage;
public DateTime TimeStamp => info.TimeStamp;
public string LongMessage => info.FormattedMessage;
public LogLevel Level => info.Level;
}

}
7 changes: 6 additions & 1 deletion Wabbajack.App.Wpf/Views/Common/LogView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<CollectionViewSource x:Key="FilteredItems"
Source="{Binding LoggerProvider.MessageLog}"
Filter="FilteredItems_OnFilter" />
</Grid.Resources>
<Rectangle Fill="{StaticResource HeatedBorderBrush}" Opacity="{Binding ProgressPercent, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
<ListBox
local:AutoScrollBehavior.ScrollOnNewItem="True"
BorderBrush="Transparent"
BorderThickness="1"
ItemsSource="{Binding LoggerProvider.MessageLog}"
ItemsSource="{Binding Source={StaticResource FilteredItems}}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
Expand Down
11 changes: 10 additions & 1 deletion Wabbajack.App.Wpf/Views/Common/LogView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Windows;
using Microsoft.Extensions.Logging;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using static Wabbajack.Models.LogStream;

namespace Wabbajack
{
Expand All @@ -16,6 +19,12 @@ public double ProgressPercent
public static readonly DependencyProperty ProgressPercentProperty = DependencyProperty.Register(nameof(ProgressPercent), typeof(double), typeof(LogView),
new FrameworkPropertyMetadata(default(double)));

private void FilteredItems_OnFilter(object sender, FilterEventArgs e)
{
var item = e.Item as ILogMessage;
e.Accepted = item.Level.Ordinal > 3;
}

public LogView()
{
InitializeComponent();
Expand Down
Loading