diff --git a/Robust.Client/GameController/GameController.cs b/Robust.Client/GameController/GameController.cs index 5e17d9313..de2c8543b 100644 --- a/Robust.Client/GameController/GameController.cs +++ b/Robust.Client/GameController/GameController.cs @@ -277,12 +277,15 @@ namespace Robust.Client return new ResourceManifestData(modules, assemblyPrefix, defaultWindowTitle, windowIconSet, splashLogo, autoConnect); } - internal bool StartupSystemSplash(GameControllerOptions options, Func? logHandlerFactory) + internal bool StartupSystemSplash( + GameControllerOptions options, + Func? logHandlerFactory, + bool globalExceptionLog = false) { Options = options; ReadInitialLaunchState(); - SetupLogging(_logManager, logHandlerFactory ?? (() => new ConsoleLogHandler())); + SetupLogging(_logManager, logHandlerFactory ?? (() => new ConsoleLogHandler()), globalExceptionLog); if (_commandLineArgs != null) { @@ -599,7 +602,10 @@ namespace Robust.Client } } - internal static void SetupLogging(ILogManager logManager, Func logHandlerFactory) + internal static void SetupLogging( + ILogManager logManager, + Func logHandlerFactory, + bool globalExceptionLog) { logManager.RootSawmill.AddHandler(logHandlerFactory()); @@ -616,34 +622,37 @@ namespace Robust.Client logManager.GetSawmill("szr").Level = LogLevel.Info; logManager.GetSawmill("loc").Level = LogLevel.Warning; + if (globalExceptionLog) + { #if DEBUG_ONLY_FCE_INFO #if DEBUG_ONLY_FCE_LOG - var fce = logManager.GetSawmill("fce"); + var fce = logManager.GetSawmill("fce"); #endif - AppDomain.CurrentDomain.FirstChanceException += (sender, args) => - { - // TODO: record FCE stats + AppDomain.CurrentDomain.FirstChanceException += (sender, args) => + { + // TODO: record FCE stats #if DEBUG_ONLY_FCE_LOG - fce.Fatal(message); + fce.Fatal(message); #endif - } + } #endif - var uh = logManager.GetSawmill("unhandled"); - AppDomain.CurrentDomain.UnhandledException += (sender, args) => - { - var message = ((Exception)args.ExceptionObject).ToString(); - uh.Log(args.IsTerminating ? LogLevel.Fatal : LogLevel.Error, message); - }; + var uh = logManager.GetSawmill("unhandled"); + AppDomain.CurrentDomain.UnhandledException += (sender, args) => + { + var message = ((Exception)args.ExceptionObject).ToString(); + uh.Log(args.IsTerminating ? LogLevel.Fatal : LogLevel.Error, message); + }; - var uo = logManager.GetSawmill("unobserved"); - TaskScheduler.UnobservedTaskException += (sender, args) => - { - uo.Error(args.Exception!.ToString()); + var uo = logManager.GetSawmill("unobserved"); + TaskScheduler.UnobservedTaskException += (sender, args) => + { + uo.Error(args.Exception!.ToString()); #if EXCEPTION_TOLERANCE - args.SetObserved(); // don't crash + args.SetObserved(); // don't crash #endif - }; + }; + } } private string GetUserDataDir() diff --git a/Robust.UnitTesting/RobustIntegrationTest.cs b/Robust.UnitTesting/RobustIntegrationTest.cs index fa47c5137..9d9d4dbe1 100644 --- a/Robust.UnitTesting/RobustIntegrationTest.cs +++ b/Robust.UnitTesting/RobustIntegrationTest.cs @@ -828,7 +828,10 @@ namespace Robust.UnitTesting client.OverrideMainLoop(GameLoop); client.ContentStart = Options?.ContentStart ?? false; - client.StartupSystemSplash(clientOptions, () => new TestLogHandler(cfg, "CLIENT")); + client.StartupSystemSplash( + clientOptions, + () => new TestLogHandler(cfg, "CLIENT"), + globalExceptionLog: false); client.StartupContinue(GameController.DisplayMode.Headless); GameLoop.RunInit();