From 1ac3bab5fe79140848e962b05ee95e40ecf23532 Mon Sep 17 00:00:00 2001 From: Isaac Daly Date: Thu, 27 Jun 2024 20:58:39 +1000 Subject: [PATCH] Add logging to `Store` calls (#915) Improve traceability of the sector data store by adding logs for each `Transform` and `Picker`. --- src/Whim/Context/CoreSavedStateManager.cs | 6 +++++- src/Whim/Store/Store.cs | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Whim/Context/CoreSavedStateManager.cs b/src/Whim/Context/CoreSavedStateManager.cs index 9a788fc82..883c83138 100644 --- a/src/Whim/Context/CoreSavedStateManager.cs +++ b/src/Whim/Context/CoreSavedStateManager.cs @@ -56,7 +56,11 @@ protected virtual void Dispose(bool disposing) if (disposing) { // dispose managed state (managed objects) - SaveState(); + try + { + SaveState(); + } + catch (Exception) { } } _disposedValue = true; diff --git a/src/Whim/Store/Store.cs b/src/Whim/Store/Store.cs index 307653c96..1f275105b 100644 --- a/src/Whim/Store/Store.cs +++ b/src/Whim/Store/Store.cs @@ -67,6 +67,8 @@ public Result Dispatch(Transform transform) { return Task.Run(() => { + Logger.Debug($"Entering task, executing transform {transform}"); + try { _lock.EnterWriteLock(); @@ -80,6 +82,7 @@ public Result Dispatch(Transform transform) }).Result; } + Logger.Debug($"Executing transform {transform}"); return DispatchFn(transform); } @@ -93,6 +96,8 @@ public TResult Pick(Picker picker) { return Task.Run(() => { + Logger.Debug($"Entering task, executing picker {picker}"); + try { _lock.EnterReadLock(); @@ -105,6 +110,7 @@ public TResult Pick(Picker picker) }).Result; } + Logger.Debug($"Executing picker {picker}"); return PickFn(picker); } @@ -117,6 +123,7 @@ public TResult Pick(PurePicker picker) { return Task.Run(() => { + Logger.Debug($"Entering task, executing picker {picker}"); try { _lock.EnterReadLock(); @@ -129,6 +136,7 @@ public TResult Pick(PurePicker picker) }).Result; } + Logger.Debug($"Executing picker {picker}"); return PurePickFn(picker); }