diff --git a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs index 45aa675..7d66175 100644 --- a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs +++ b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs @@ -21,6 +21,7 @@ public class MareConfig : IMareConfiguration public bool InitialScanComplete { get; set; } = false; public LogLevel LogLevel { get; set; } = LogLevel.Information; public bool LogPerformance { get; set; } = false; + public bool LogEvents { get; set; } = true; public double MaxLocalCacheInGiB { get; set; } = 20; public bool OpenGposeImportOnGposeStart { get; set; } = false; public bool OpenPopupOnAdd { get; set; } = true; diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs index 48f962e..c5189ad 100644 --- a/MareSynchronos/Plugin.cs +++ b/MareSynchronos/Plugin.cs @@ -92,8 +92,7 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton(); - collection.AddSingleton((s) => new EventAggregator(pluginInterface.ConfigDirectory.FullName, - s.GetRequiredService>(), s.GetRequiredService())); + collection.AddSingleton(); collection.AddSingleton((s) => new DalamudUtilService(s.GetRequiredService>(), clientState, objectTable, framework, gameGui, toastGui, condition, gameData, targetManager, s.GetRequiredService(), s.GetRequiredService())); diff --git a/MareSynchronos/Services/Events/EventAggregator.cs b/MareSynchronos/Services/Events/EventAggregator.cs index c8c35e5..b2b4ed2 100644 --- a/MareSynchronos/Services/Events/EventAggregator.cs +++ b/MareSynchronos/Services/Events/EventAggregator.cs @@ -1,4 +1,5 @@ -using MareSynchronos.Services.Mediator; +using MareSynchronos.MareConfiguration; +using MareSynchronos.Services.Mediator; using MareSynchronos.Utils; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -18,19 +19,22 @@ public class EventAggregator : MediatorSubscriberBase, IHostedService private string CurrentLogName => $"{DateTime.Now:yyyy-MM-dd}-events.log"; private DateTime _currentTime; - public EventAggregator(string configDirectory, ILogger logger, MareMediator mareMediator) : base(logger, mareMediator) + public EventAggregator(MareConfigService configService, ILogger logger, MareMediator mareMediator) : base(logger, mareMediator) { Logger.LogInformation("Starting EventAggregatorService"); Logger.LogInformation("Started EventAggregatorService"); + _configDirectory = configService.ConfigurationDirectory; + _logger = logger; + _currentTime = DateTime.UnixEpoch; Mediator.Subscribe(this, (msg) => { _lock.Wait(); try { - Logger.LogTrace("Received Event: {evt}", msg.Event.ToString()); _events.Add(msg.Event); - WriteToFile(msg.Event); + if (configService.Current.LogEvents) + WriteToFile(msg.Event); } finally { @@ -41,9 +45,6 @@ public class EventAggregator : MediatorSubscriberBase, IHostedService }); EventList = CreateEventLazy(); - _configDirectory = configDirectory; - _logger = logger; - _currentTime = DateTime.Now - TimeSpan.FromDays(1); } private void RecreateLazy() diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index 5e3406c..e855c50 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -661,6 +661,13 @@ public class SettingsUi : WindowMediatorSubscriberBase { _performanceCollector.PrintPerformanceStats(60); } + + bool logEvents = _configService.Current.LogEvents; + if (ImGui.Checkbox("Log Event Viewer Data", ref logEvents)) + { + _configService.Current.LogEvents = logEvents; + _configService.Save(); + } } private void DrawFileStorageSettings()