From 558886e0ed24774013fd97b967cf2dd579f321c9 Mon Sep 17 00:00:00 2001 From: Halgari Date: Thu, 6 Oct 2022 16:54:01 -0600 Subject: [PATCH] Fix some log creation issues and tests --- Wabbajack.App.Wpf/App.xaml.cs | 5 ++++- Wabbajack.Installer.Test/Startup.cs | 2 ++ Wabbajack.Services.OSIntegrated/ServiceExtensions.cs | 2 +- .../ThrowingUserInterventionHandler.cs | 12 ++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 Wabbajack.Services.OSIntegrated/ThrowingUserInterventionHandler.cs diff --git a/Wabbajack.App.Wpf/App.xaml.cs b/Wabbajack.App.Wpf/App.xaml.cs index c4289cb7..cceecbb0 100644 --- a/Wabbajack.App.Wpf/App.xaml.cs +++ b/Wabbajack.App.Wpf/App.xaml.cs @@ -50,7 +50,10 @@ namespace Wabbajack { var config = new NLog.Config.LoggingConfiguration(); - var logFolder = KnownFolders.LauncherAwarePath; + var logFolder = KnownFolders.LauncherAwarePath.Combine("logs"); + if (!logFolder.DirectoryExists()) + logFolder.CreateDirectory(); + var fileTarget = new FileTarget("file") { FileName = logFolder.Combine("Wabbajack.current.log").ToString(), diff --git a/Wabbajack.Installer.Test/Startup.cs b/Wabbajack.Installer.Test/Startup.cs index c1dc6195..f186af7c 100644 --- a/Wabbajack.Installer.Test/Startup.cs +++ b/Wabbajack.Installer.Test/Startup.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Wabbajack.DTOs.Interventions; using Wabbajack.Services.OSIntegrated; using Xunit.DependencyInjection; using Xunit.DependencyInjection.Logging; @@ -10,6 +11,7 @@ public class Startup { public void ConfigureServices(IServiceCollection service) { + service.AddSingleton(); service.AddOSIntegrated(o => { o.UseLocalCache = true; diff --git a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs index f8b3897b..19e01ae6 100644 --- a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs +++ b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs @@ -90,7 +90,7 @@ public static class ServiceExtensions EncryptedDataLocation = KnownFolders.WabbajackAppLocal.Combine("encrypted"), ModListsDownloadLocation = KnownFolders.EntryPoint.Combine("downloaded_mod_lists"), SavedSettingsLocation = KnownFolders.WabbajackAppLocal.Combine("saved_settings"), - LogLocation = KnownFolders.EntryPoint.Combine("logs"), + LogLocation = KnownFolders.LauncherAwarePath.Combine("logs"), ImageCacheLocation = KnownFolders.WabbajackAppLocal.Combine("image_cache") }); diff --git a/Wabbajack.Services.OSIntegrated/ThrowingUserInterventionHandler.cs b/Wabbajack.Services.OSIntegrated/ThrowingUserInterventionHandler.cs new file mode 100644 index 00000000..943a867b --- /dev/null +++ b/Wabbajack.Services.OSIntegrated/ThrowingUserInterventionHandler.cs @@ -0,0 +1,12 @@ +using System; +using Wabbajack.DTOs.Interventions; + +namespace Wabbajack.Services.OSIntegrated; + +public class ThrowingUserInterventionHandler : IUserInterventionHandler +{ + public void Raise(IUserIntervention intervention) + { + throw new Exception("Unexpected user intervention, this should throw"); + } +} \ No newline at end of file