mirror of
https://github.com/4sval/FModel.git
synced 2026-12-05 07:42:19 -06:00
Debug
This commit is contained in:
Submodule CUE4Parse updated: df14b992d6...f2cd2c4bcf
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
2
Snooper
2
Snooper
Submodule Snooper updated: bb5c2a0239...5a852b1841
Reference in New Issue
Block a user