Added logging to the EventService.

This commit is contained in:
Maplewheels
2026-02-02 02:59:43 -05:00
parent 0cab7954f8
commit 024b07d5f4

View File

@@ -51,6 +51,7 @@ public partial class EventService : IEventService
public static implicit operator TypeStringKey(string typeName) => new(typeName);
}
private ILoggerService _loggerService;
private readonly AsyncReaderWriterLock _operationsLock = new();
private readonly ConcurrentDictionary<TypeStringKey, ConcurrentDictionary<OneOf<IEvent, string>, IEvent>> _subscribers = new();
private readonly ConcurrentDictionary<TypeStringKey, (TypeStringKey Event, Func<LuaCsFunc, IEvent> RunnerFactory)> _luaAliasEventFactory = new();
@@ -73,6 +74,11 @@ public partial class EventService : IEventService
private int _isDisposed;
public EventService(ILoggerService loggerService)
{
_loggerService = loggerService;
}
public bool IsDisposed
{
get => ModUtils.Threading.GetBool(ref _isDisposed);
@@ -140,6 +146,7 @@ public partial class EventService : IEventService
}
catch (Exception e)
{
_loggerService.LogError(e.Message);
#if DEBUG
throw;
#endif
@@ -282,6 +289,7 @@ public partial class EventService : IEventService
catch (Exception e)
{
results.WithError(new ExceptionalError(e));
_loggerService.LogError(e.Message);
#if DEBUG
throw;
#endif