Remove static Logger usages from GameController. (#4132)

This commit is contained in:
Vera Aguilera Puerto
2023-06-10 00:10:30 +02:00
committed by GitHub
parent 82e1a1003f
commit 3160437e0f
4 changed files with 19 additions and 13 deletions

View File

@@ -27,7 +27,7 @@ internal partial class GameController
// Otherwise abuse could happen.
DebugTools.AssertNotNull(_mainLoop);
Logger.Info($"Attempting redial of {address}: {text ?? "no reason given"}");
_logger.Info($"Attempting redial of {address}: {text ?? "no reason given"}");
if (!_mainLoop!.Running)
{

View File

@@ -20,7 +20,7 @@ namespace Robust.Client
LoadRobustWebView(mode);
break;
default:
Logger.Error($"Unknown Robust module: {module}");
_logger.Error($"Unknown Robust module: {module}");
return;
}
}
@@ -28,7 +28,7 @@ namespace Robust.Client
private void LoadRobustWebView(GameController.DisplayMode mode)
{
Logger.Debug("Loading Robust.Client.WebView");
_logger.Debug("Loading Robust.Client.WebView");
var alc = CreateModuleLoadContext("Robust.Client.WebView");
var assembly = alc.LoadFromAssemblyName(new AssemblyName("Robust.Client.WebView"));
@@ -39,7 +39,7 @@ namespace Robust.Client
_webViewHook = (IWebViewManagerHook)Activator.CreateInstance(managerType)!;
_webViewHook.PreInitialize(_dependencyCollection, mode);
Logger.Debug("Done pre-initializing Robust.Client.WebView");
_logger.Debug("Done pre-initializing Robust.Client.WebView");
}
/// <summary>

View File

@@ -10,7 +10,7 @@ using Robust.Shared.Utility;
namespace Robust.Client
{
internal partial class GameController
internal partial class GameController : IPostInjectInit
{
private IGameLoop? _mainLoop;
@@ -20,6 +20,7 @@ namespace Robust.Client
private static bool _hasStarted;
private Thread? _gameThread;
private ISawmill _logger = default!;
public static void Main(string[] args)
{
@@ -73,7 +74,7 @@ namespace Robust.Client
{
if (!StartupSystemSplash(options, logHandlerFactory))
{
Logger.Fatal("Failed to start game controller!");
_logger.Fatal("Failed to start game controller!");
return;
}
@@ -96,7 +97,7 @@ namespace Robust.Client
if (_gameThread.IsAlive)
{
Logger.Debug("Window loop exited; waiting for game thread to exit");
_logger.Debug("Window loop exited; waiting for game thread to exit");
_gameThread.Join();
}
}
@@ -107,7 +108,7 @@ namespace Robust.Client
CleanupWindowThread();
Logger.Debug("Goodbye");
_logger.Debug("Goodbye");
_dependencyCollection.Clear();
}
@@ -125,7 +126,7 @@ namespace Robust.Client
{
if (!StartupContinue(mode))
{
Logger.Fatal("Failed to start game controller!");
_logger.Fatal("Failed to start game controller!");
return;
}
@@ -134,5 +135,10 @@ namespace Robust.Client
CleanupGameThread();
}
void IPostInjectInit.PostInject()
{
_logger = _logManager.GetSawmill("game");
}
}
}

View File

@@ -270,7 +270,7 @@ namespace Robust.Client
if (!result)
{
Logger.Fatal("Errors while loading content assemblies.");
_logger.Fatal("Errors while loading content assemblies.");
return false;
}
@@ -508,7 +508,7 @@ namespace Robust.Client
if (uri.Scheme != "udp")
{
Logger.Warning($"connect-address '{uri}' does not have URI scheme of udp://..");
_logger.Warning($"connect-address '{uri}' does not have URI scheme of udp://..");
}
LaunchState = new InitialLaunchState(
@@ -531,11 +531,11 @@ namespace Robust.Client
if (reason != null)
{
Logger.Info($"Shutting down! Reason: {reason}");
_logger.Info($"Shutting down! Reason: {reason}");
}
else
{
Logger.Info("Shutting down!");
_logger.Info("Shutting down!");
}
_mainLoop.Running = false;