diff --git a/CUE4Parse b/CUE4Parse index df14b992..f2cd2c4b 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit df14b992d6d503c9d39e693af415fee5e1961de9 +Subproject commit f2cd2c4bcfbf7f125f46b971427e1273e0b0a7db diff --git a/FModel/App.xaml.cs b/FModel/App.xaml.cs index e22005af..93c06aff 100644 --- a/FModel/App.xaml.cs +++ b/FModel/App.xaml.cs @@ -4,6 +4,7 @@ using Serilog; using System; using System.Globalization; using System.IO; +using System.Linq; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Threading; @@ -114,17 +115,30 @@ public partial class App #if DEBUG var filePath = Path.Combine(UserSettings.Default.OutputDirectory, "Logs", $"FModel-Debug-Log-{DateTime.Now:yyyy-MM-dd}.log"); + + var viewerContexts = typeof(Snooper.Hosting.Bridge).Assembly.GetTypes() + .Concat(typeof(EditorWindow).Assembly.GetTypes()) + .Select(type => type.Name) + .Append("Snooper") + .ToHashSet(StringComparer.Ordinal); #else var filePath = Path.Combine(UserSettings.Default.OutputDirectory, "Logs", $"FModel-Log-{DateTime.Now:yyyy-MM-dd}.log"); #endif const string template1 = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}"; const string template2 = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{ClassName}] {ObjectPath}: {Message:lj}{NewLine}{Exception}"; + Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Verbose() #endif .Enrich.FromLogContext() .Enrich.WithProperty("SourceContext", "FModel") +#if DEBUG + .Filter.ByExcluding(e => UserSettings.Default.SuppressViewerLogs && e.Level < LogEventLevel.Fatal && + e.Properties.TryGetValue("SourceContext", out var source) && + source is ScalarValue { Value: string context } && + viewerContexts.Contains(context)) +#endif .WriteTo.Logger(lc => lc .Filter.ByExcluding(IsConversionLibrary) .WriteTo.Console(outputTemplate: template1, theme: AnsiConsoleTheme.Literate) diff --git a/FModel/Framework/FModelBridgeHost.cs b/FModel/Framework/FModelBridgeHost.cs index e51529bc..792c8c1b 100644 --- a/FModel/Framework/FModelBridgeHost.cs +++ b/FModel/Framework/FModelBridgeHost.cs @@ -26,4 +26,16 @@ public sealed class FModelBridgeHost : IBridgeHost window.Topmost = false; }); } + +#if DEBUG + public bool SuppressViewerLogs + { + get => UserSettings.Default.SuppressViewerLogs; + set + { + UserSettings.Default.SuppressViewerLogs = value; + UserSettings.Save(); + } + } +#endif } diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs index 4f254031..ebe567f7 100644 --- a/FModel/Settings/UserSettings.cs +++ b/FModel/Settings/UserSettings.cs @@ -20,6 +20,8 @@ public sealed class UserSettings : ViewModel { public static UserSettings Default { get; set; } #if DEBUG + public bool SuppressViewerLogs { get; set; } + public static readonly string FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FModel", "AppSettings_Debug.json"); #else public static readonly string FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FModel", "AppSettings.json"); diff --git a/Snooper b/Snooper index bb5c2a02..5a852b18 160000 --- a/Snooper +++ b/Snooper @@ -1 +1 @@ -Subproject commit bb5c2a0239661d40e145bb1a2620aa3e18457bcc +Subproject commit 5a852b184133510a9cae8657da50fe12f6bbf365