From 6b0daf6d7fe4f5ccf4c6f4b24781dfb247fb0dfb Mon Sep 17 00:00:00 2001 From: Dominion Date: Tue, 28 Feb 2023 12:23:01 -0500 Subject: [PATCH] Fix bad logging in port allocator --- src/Tgstation.Server.Host/Core/PortAllocator.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/PortAllocator.cs b/src/Tgstation.Server.Host/Core/PortAllocator.cs index 6951ba605a..31309deed8 100644 --- a/src/Tgstation.Server.Host/Core/PortAllocator.cs +++ b/src/Tgstation.Server.Host/Core/PortAllocator.cs @@ -59,7 +59,7 @@ namespace Tgstation.Server.Host.Core /// public async Task GetAvailablePort(ushort basePort, bool checkOne, CancellationToken cancellationToken) { - logger.LogTrace("Port allocation >= {0} requested...", basePort); + logger.LogTrace("Port allocation >= {basePort} requested...", basePort); var ddPorts = await databaseContext .DreamDaemonSettings @@ -101,16 +101,25 @@ namespace Tgstation.Server.Host.Core continue; } - logger.LogInformation("Allocated port {0}", port); + logger.LogInformation("Allocated port {port}", port); return port; } - logger.LogWarning("Unable to allocate port >= {0}!", basePort); + logger.LogWarning("Unable to allocate port >= {basePort}!", basePort); return null; } finally { - logger.LogDebug(new AggregateException(exceptions), "Failed to allocate ports {0}-{1}!", basePort, port - 1); + if (port != basePort) + { + logger.LogDebug( + exceptions.Count == 1 + ? exceptions.First() + : new AggregateException(exceptions), + "Failed to allocate ports {basePort}-{lastCheckedPort}!", + basePort, + port - 1); + } } } }