Skip to content

Commit

Permalink
Handle once mode beter
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Feb 16, 2024
1 parent ee3efe7 commit b97773e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/thirdparty/Monologue/Monologuer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ public void LogDoubleArray(string path, LogType logType, ReadOnlySpan<double> va
}
}

private readonly HashSet<string> sentOnceKeys = [];

private ref TypedLogs<TNT, TDataLog> CheckDoLog<TNT, TDataLog>(string path,
ref LogType logType, LogLevel logLevel, Dictionary<string, TypedLogs<TNT, TDataLog>> dict)
where TNT : class, IPublisher
Expand All @@ -230,13 +228,14 @@ private ref TypedLogs<TNT, TDataLog> CheckDoLog<TNT, TDataLog>(string path,
// We have the once flag, we need to check if we've already sent the path
if ((logType & LogType.Once) != 0)
{
if (!sentOnceKeys.Add(path))
ref var onceRef = ref CollectionsMarshal.GetValueRefOrAddDefault(dict, path, out bool exists);
// If we've already done a write, do nothing
if (exists)
{
return ref Unsafe.NullRef<TypedLogs<TNT, TDataLog>>();
}
// Unconditionally write if we're a once flag.

return ref CollectionsMarshal.GetValueRefOrAddDefault(dict, path, out _);
// Otherwise do a single write
return ref onceRef;
}

// If we're override file only, we're unconditionally logging
Expand Down

0 comments on commit b97773e

Please sign in to comment.