Allow event logging to be disabled
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -92,8 +92,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton<FileCompactor>();
|
||||
collection.AddSingleton<TagHandler>();
|
||||
collection.AddSingleton<UidDisplayHandler>();
|
||||
collection.AddSingleton((s) => new EventAggregator(pluginInterface.ConfigDirectory.FullName,
|
||||
s.GetRequiredService<ILogger<EventAggregator>>(), s.GetRequiredService<MareMediator>()));
|
||||
collection.AddSingleton<EventAggregator>();
|
||||
collection.AddSingleton((s) => new DalamudUtilService(s.GetRequiredService<ILogger<DalamudUtilService>>(),
|
||||
clientState, objectTable, framework, gameGui, toastGui, condition, gameData, targetManager,
|
||||
s.GetRequiredService<MareMediator>(), s.GetRequiredService<PerformanceCollectorService>()));
|
||||
|
||||
@@ -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,18 +19,21 @@ public class EventAggregator : MediatorSubscriberBase, IHostedService
|
||||
private string CurrentLogName => $"{DateTime.Now:yyyy-MM-dd}-events.log";
|
||||
private DateTime _currentTime;
|
||||
|
||||
public EventAggregator(string configDirectory, ILogger<EventAggregator> logger, MareMediator mareMediator) : base(logger, mareMediator)
|
||||
public EventAggregator(MareConfigService configService, ILogger<EventAggregator> logger, MareMediator mareMediator) : base(logger, mareMediator)
|
||||
{
|
||||
Logger.LogInformation("Starting EventAggregatorService");
|
||||
Logger.LogInformation("Started EventAggregatorService");
|
||||
_configDirectory = configService.ConfigurationDirectory;
|
||||
_logger = logger;
|
||||
_currentTime = DateTime.UnixEpoch;
|
||||
|
||||
Mediator.Subscribe<EventMessage>(this, (msg) =>
|
||||
{
|
||||
_lock.Wait();
|
||||
try
|
||||
{
|
||||
Logger.LogTrace("Received Event: {evt}", msg.Event.ToString());
|
||||
_events.Add(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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user