Skip to content

Commit

Permalink
Merge pull request #6493 from peppy/logging-init-method
Browse files Browse the repository at this point in the history
Add entry point to `Game` for logging setup purposes
  • Loading branch information
peppy authored Jan 15, 2025
2 parents 1696bad + 2c02900 commit cd1e303
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions osu.Framework/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ protected Game()

protected sealed override void AddInternal(Drawable drawable) => throw new InvalidOperationException($"Use {nameof(Add)} or {nameof(Content)} instead.");

/// <summary>
/// The earliest point of entry during <see cref="GameHost.Run"/> starting execution of a game.
/// This should be used to set up any low level tasks such as exception handling.
/// </summary>
/// <remarks>
/// At this point in execution, only <see cref="GameHost.Storage"/> and <see cref="GameHost.CacheStorage"/> are guaranteed to be valid for use.
/// They are provided as <paramref name="gameStorage"/> and <paramref name="cacheStorage"/> respectively for convenience.
/// </remarks>
/// <param name="gameStorage">The default game storage.</param>
/// <param name="cacheStorage">The default cache storage.</param>
public virtual void SetupLogging(Storage gameStorage, Storage cacheStorage)
{
}

/// <summary>
/// As Load is run post host creation, you can override this method to alter properties of the host before it makes itself visible to the user.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions osu.Framework/Platform/GameHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ public void Run(Game game)
CacheStorage = GetDefaultGameStorage().GetStorageForDirectory("cache");

SetupForRun();
game.SetupLogging(Storage, CacheStorage);

populateInputHandlers();

Expand Down

0 comments on commit cd1e303

Please sign in to comment.