Skip to content

Commit

Permalink
Add logging to Store calls (#915)
Browse files Browse the repository at this point in the history
Improve traceability of the sector data store by adding logs for each `Transform` and `Picker`.
  • Loading branch information
dalyIsaac authored Jun 27, 2024
1 parent b06e7c7 commit 1ac3bab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Whim/Context/CoreSavedStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
// dispose managed state (managed objects)
SaveState();
try
{
SaveState();
}
catch (Exception) { }
}

_disposedValue = true;
Expand Down
8 changes: 8 additions & 0 deletions src/Whim/Store/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public Result<TResult> Dispatch<TResult>(Transform<TResult> transform)
{
return Task.Run(() =>
{
Logger.Debug($"Entering task, executing transform {transform}");

try
{
_lock.EnterWriteLock();
Expand All @@ -80,6 +82,7 @@ public Result<TResult> Dispatch<TResult>(Transform<TResult> transform)
}).Result;
}

Logger.Debug($"Executing transform {transform}");
return DispatchFn(transform);
}

Expand All @@ -93,6 +96,8 @@ public TResult Pick<TResult>(Picker<TResult> picker)
{
return Task.Run(() =>
{
Logger.Debug($"Entering task, executing picker {picker}");

try
{
_lock.EnterReadLock();
Expand All @@ -105,6 +110,7 @@ public TResult Pick<TResult>(Picker<TResult> picker)
}).Result;
}

Logger.Debug($"Executing picker {picker}");
return PickFn(picker);
}

Expand All @@ -117,6 +123,7 @@ public TResult Pick<TResult>(PurePicker<TResult> picker)
{
return Task.Run(() =>
{
Logger.Debug($"Entering task, executing picker {picker}");
try
{
_lock.EnterReadLock();
Expand All @@ -129,6 +136,7 @@ public TResult Pick<TResult>(PurePicker<TResult> picker)
}).Result;
}

Logger.Debug($"Executing picker {picker}");
return PurePickFn(picker);
}

Expand Down

0 comments on commit 1ac3bab

Please sign in to comment.