New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't clear Logger.NewEntry
handlers when flushing
#6191
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instead, clearing `NewEntry` is done only when the `GameHost` is disposing.
Susko3
changed the title
Don't clear
Don't clear Feb 19, 2024
Logger.NewEntry
when flushingLogger.NewEntry
handlers when flushing
2 tasks
frenzibyte
previously approved these changes
Feb 19, 2024
peppy
requested changes
Feb 20, 2024
osu.Framework/Logging/Logger.cs
Outdated
/// Pause execution until all logger writes have completed and file handles have been closed. | ||
/// This will also unbind all handlers bound to <see cref="NewEntry"/>. | ||
/// </summary> | ||
public static void Dispose() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static Dispose
feels very wrong to me.
diff --git a/osu.Framework/Logging/Logger.cs b/osu.Framework/Logging/Logger.cs
index 69be3f974..c997ea80b 100644
--- a/osu.Framework/Logging/Logger.cs
+++ b/osu.Framework/Logging/Logger.cs
@@ -479,10 +479,9 @@ public static void Flush()
}
/// <summary>
- /// Pause execution until all logger writes have completed and file handles have been closed.
- /// This will also unbind all handlers bound to <see cref="NewEntry"/>.
+ /// Perform a <see cref="Flush"/> and unbind all events in preparation for game host shutdown.
/// </summary>
- public static void Dispose()
+ internal static void FlushForShutdown()
{
Flush();
NewEntry = null;
diff --git a/osu.Framework/Platform/GameHost.cs b/osu.Framework/Platform/GameHost.cs
index e6b4c42ba..09b132787 100644
--- a/osu.Framework/Platform/GameHost.cs
+++ b/osu.Framework/Platform/GameHost.cs
@@ -396,7 +396,7 @@ private void abortExecutionFromException(object sender, Exception exception, boo
// In the case of an unhandled exception, it's feasible that the disposal flow for `GameHost` doesn't run.
// This can result in the exception not being logged (or being partially logged) due to the logger running asynchronously.
// We force flushing the logger here to ensure logging completes (and also unbind in the process since we're aborting execution from here).
- Logger.Dispose();
+ Logger.FlushForShutdown();
var captured = ExceptionDispatchInfo.Capture(exception);
var thrownEvent = new ManualResetEventSlim(false);
@@ -1391,7 +1391,7 @@ protected virtual void Dispose(bool disposing)
Window?.Dispose();
LoadingComponentsLogger.LogAndFlush();
- Logger.Dispose();
+ Logger.FlushForShutdown();
}
public void Dispose()
peppy
approved these changes
Feb 22, 2024
frenzibyte
approved these changes
Feb 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead,
NewEntry
is cleared only when theGameHost
is disposing.This allows using
Logger.Flush()
when exporting logs from osu!, the specific use case is to log global statistics:Clearing
NewEntry
when exporting logs is undesirable.