From c4cf45776d6df173f8e414dbd2e78a447f11e361 Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Wed, 25 Jan 2023 05:04:28 +0100 Subject: [PATCH] Refactor PhantomLogger overloads --- .../Phantom.Agent.Minecraft/Java/JavaRuntimeDiscovery.cs | 2 +- Agent/Phantom.Agent.Rpc/ServerMessaging.cs | 2 +- Agent/Phantom.Agent/AgentKey.cs | 2 +- Agent/Phantom.Agent/GuidFile.cs | 2 +- Common/Phantom.Common.Logging/PhantomLogger.cs | 8 ++++---- Server/Phantom.Server/CertificateFiles.cs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Agent/Phantom.Agent.Minecraft/Java/JavaRuntimeDiscovery.cs b/Agent/Phantom.Agent.Minecraft/Java/JavaRuntimeDiscovery.cs index d7b76bb..dc1bc7b 100644 --- a/Agent/Phantom.Agent.Minecraft/Java/JavaRuntimeDiscovery.cs +++ b/Agent/Phantom.Agent.Minecraft/Java/JavaRuntimeDiscovery.cs @@ -7,7 +7,7 @@ using Serilog; namespace Phantom.Agent.Minecraft.Java; public sealed class JavaRuntimeDiscovery { - private static readonly ILogger Logger = PhantomLogger.Create(typeof(JavaRuntimeDiscovery)); + private static readonly ILogger Logger = PhantomLogger.Create(nameof(JavaRuntimeDiscovery)); public static string? GetSystemSearchPath() { const string LinuxJavaPath = "/usr/lib/jvm"; diff --git a/Agent/Phantom.Agent.Rpc/ServerMessaging.cs b/Agent/Phantom.Agent.Rpc/ServerMessaging.cs index 318563e..9c067cd 100644 --- a/Agent/Phantom.Agent.Rpc/ServerMessaging.cs +++ b/Agent/Phantom.Agent.Rpc/ServerMessaging.cs @@ -5,7 +5,7 @@ using Serilog; namespace Phantom.Agent.Rpc; public static class ServerMessaging { - private static readonly ILogger Logger = PhantomLogger.Create(typeof(ServerMessaging)); + private static readonly ILogger Logger = PhantomLogger.Create(nameof(ServerMessaging)); private static RpcServerConnection? CurrentConnection { get; set; } private static RpcServerConnection CurrentConnectionOrThrow => CurrentConnection ?? throw new InvalidOperationException("Server connection not ready."); diff --git a/Agent/Phantom.Agent/AgentKey.cs b/Agent/Phantom.Agent/AgentKey.cs index 0fc2eac..c852820 100644 --- a/Agent/Phantom.Agent/AgentKey.cs +++ b/Agent/Phantom.Agent/AgentKey.cs @@ -8,7 +8,7 @@ using Serilog; namespace Phantom.Agent; static class AgentKey { - private static ILogger Logger { get; } = PhantomLogger.Create(typeof(AgentKey)); + private static ILogger Logger { get; } = PhantomLogger.Create(nameof(AgentKey)); public static Task<(NetMQCertificate, AgentAuthToken)?> Load(string? agentKeyToken, string? agentKeyFilePath) { if (agentKeyFilePath != null) { diff --git a/Agent/Phantom.Agent/GuidFile.cs b/Agent/Phantom.Agent/GuidFile.cs index f222e8b..481bd32 100644 --- a/Agent/Phantom.Agent/GuidFile.cs +++ b/Agent/Phantom.Agent/GuidFile.cs @@ -6,7 +6,7 @@ using Serilog; namespace Phantom.Agent; static class GuidFile { - private static ILogger Logger { get; } = PhantomLogger.Create(typeof(GuidFile)); + private static ILogger Logger { get; } = PhantomLogger.Create(nameof(GuidFile)); private const string GuidFileName = "agent.guid"; diff --git a/Common/Phantom.Common.Logging/PhantomLogger.cs b/Common/Phantom.Common.Logging/PhantomLogger.cs index 9a1446f..361508d 100644 --- a/Common/Phantom.Common.Logging/PhantomLogger.cs +++ b/Common/Phantom.Common.Logging/PhantomLogger.cs @@ -33,8 +33,8 @@ public static class PhantomLogger { return Base.ForContext("Category", name); } - public static ILogger Create(Type type) { - return Create(type.Name); + public static ILogger Create(string name1, string name2) { + return Create(name1 + ":" + name2); } public static ILogger Create<T>() { @@ -42,11 +42,11 @@ public static class PhantomLogger { } public static ILogger Create<T>(string name) { - return Create(typeof(T).Name + ":" + name); + return Create(typeof(T).Name, name); } public static ILogger Create<T1, T2>() { - return Create(typeof(T1).Name + ":" + typeof(T2).Name); + return Create(typeof(T1).Name, typeof(T2).Name); } public static void Dispose() { diff --git a/Server/Phantom.Server/CertificateFiles.cs b/Server/Phantom.Server/CertificateFiles.cs index d755e0b..18ef19a 100644 --- a/Server/Phantom.Server/CertificateFiles.cs +++ b/Server/Phantom.Server/CertificateFiles.cs @@ -8,7 +8,7 @@ using Serilog; namespace Phantom.Server; static class CertificateFiles { - private static ILogger Logger { get; } = PhantomLogger.Create(typeof(CertificateFiles)); + private static ILogger Logger { get; } = PhantomLogger.Create(nameof(CertificateFiles)); private const string SecretKeyFileName = "secret.key"; private const string AgentKeyFileName = "agent.key";