diff --git a/ProjectLighthouse/Configuration/ServerStatics.cs b/ProjectLighthouse/Configuration/ServerStatics.cs index 233d0eba..787967b9 100644 --- a/ProjectLighthouse/Configuration/ServerStatics.cs +++ b/ProjectLighthouse/Configuration/ServerStatics.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using LBPUnion.ProjectLighthouse.Logging; +using LBPUnion.ProjectLighthouse.Types; namespace LBPUnion.ProjectLighthouse.Configuration; @@ -25,6 +26,7 @@ public static class ServerStatics } } + // FIXME: This needs to go at some point. public static bool IsUnitTesting => AppDomain.CurrentDomain.GetAssemblies().Any(assembly => assembly.FullName!.StartsWith("xunit")); #if DEBUG @@ -32,4 +34,10 @@ public static class ServerStatics #else public static readonly bool IsDebug = false; #endif + + /// + /// The servertype, determined on startup. Shouldn't be null unless very very early in startup. + /// + // The way of doing this is kinda weird, but it works. + public static ServerType ServerType; } \ No newline at end of file diff --git a/ProjectLighthouse/Logging/Loggers/ConsoleLogger.cs b/ProjectLighthouse/Logging/Loggers/ConsoleLogger.cs index 4cc2351a..3ebc3343 100644 --- a/ProjectLighthouse/Logging/Loggers/ConsoleLogger.cs +++ b/ProjectLighthouse/Logging/Loggers/ConsoleLogger.cs @@ -11,7 +11,8 @@ public class ConsoleLogger : ILogger foreach (string line in logLine.Message.Split('\n')) { - // The following is scuffed. Beware~ + // The following is scuffed. + // Beware~ // Write the level! [Success] Console.ForegroundColor = ConsoleColor.White; diff --git a/ProjectLighthouse/Logging/Loggers/LighthouseFileLogger.cs b/ProjectLighthouse/Logging/Loggers/FileLogger.cs similarity index 62% rename from ProjectLighthouse/Logging/Loggers/LighthouseFileLogger.cs rename to ProjectLighthouse/Logging/Loggers/FileLogger.cs index 405e31a1..802263e5 100644 --- a/ProjectLighthouse/Logging/Loggers/LighthouseFileLogger.cs +++ b/ProjectLighthouse/Logging/Loggers/FileLogger.cs @@ -1,11 +1,11 @@ using System; using System.IO; +using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Files; -using LBPUnion.ProjectLighthouse.Helpers; namespace LBPUnion.ProjectLighthouse.Logging.Loggers; -public class LighthouseFileLogger : ILogger +public class FileLogger : ILogger { private static readonly string logsDirectory = Path.Combine(Environment.CurrentDirectory, "logs"); @@ -13,8 +13,8 @@ public class LighthouseFileLogger : ILogger { FileHelper.EnsureDirectoryCreated(logsDirectory); - string contentFile = $"[{line.Level}] <{line.Trace.Name}:{line.Trace.Section}> {line.Message}\n"; - string contentAll = $"[{line.Area}:{line.Level}] <{line.Trace.Name}:{line.Trace.Section}> {line.Message}\n"; + string contentFile = $"[{ServerStatics.ServerType}] [{line.Level}] <{line.Trace.Name}:{line.Trace.Section}> {line.Message}\n"; + string contentAll = $"[{ServerStatics.ServerType}] [{line.Area}:{line.Level}] <{line.Trace.Name}:{line.Trace.Section}> {line.Message}\n"; try { diff --git a/ProjectLighthouse/Startup/DebugWarmupLifetime.cs b/ProjectLighthouse/Startup/DebugWarmupLifetime.cs index 0af030c3..2161dbf4 100644 --- a/ProjectLighthouse/Startup/DebugWarmupLifetime.cs +++ b/ProjectLighthouse/Startup/DebugWarmupLifetime.cs @@ -20,7 +20,6 @@ public class DebugWarmupLifetime : IHostLifetime private CancellationTokenRegistration applicationStartedRegistration; private readonly ConsoleLifetime consoleLifetime; - public static ServerType ServerType; public DebugWarmupLifetime ( @@ -39,7 +38,7 @@ public class DebugWarmupLifetime : IHostLifetime { using HttpClient client = new(); - string url = ServerType switch + string url = ServerStatics.ServerType switch { ServerType.GameServer => ServerConfiguration.Instance.GameApiListenUrl, ServerType.Website => ServerConfiguration.Instance.WebsiteListenUrl, diff --git a/ProjectLighthouse/StartupTasks.cs b/ProjectLighthouse/StartupTasks.cs index 9df051c0..51656fd1 100644 --- a/ProjectLighthouse/StartupTasks.cs +++ b/ProjectLighthouse/StartupTasks.cs @@ -24,13 +24,11 @@ public static class StartupTasks Stopwatch stopwatch = new(); stopwatch.Start(); - #if DEBUG - DebugWarmupLifetime.ServerType = serverType; - #endif + ServerStatics.ServerType = serverType; // Setup logging Logger.Instance.AddLogger(new ConsoleLogger()); - Logger.Instance.AddLogger(new LighthouseFileLogger()); + Logger.Instance.AddLogger(new FileLogger()); Logger.Info($"Welcome to the Project Lighthouse {serverType.ToString()}!", LogArea.Startup); Logger.Info($"You are running version {VersionHelper.FullVersion}", LogArea.Startup);