Log MessageFlag name instead of numbers

This commit is contained in:
AeonLucid committed 2022-12-18 23:52:01 +01:00
1 parent 980d172d4f
commit e0b85c959b
2 files changed
+21 -2

No files matched your search

+20 -1
View File
@@ -1,4 +1,8 @@
namespace Impostor.Api.Net.Messages
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Impostor.Api.Net.Messages
{
public static class MessageFlags
{
@@ -24,5 +28,20 @@
public const byte SetActivePodType = 21;
public const byte QueryPlatformIds = 22;
public const byte QueryLobbyInfo = 23;
private static readonly Dictionary<byte, string> FlagCache;
static MessageFlags()
{
FlagCache = typeof(MessageFlags)
.GetFields(BindingFlags.Public | BindingFlags.Static)
.Where(fi => fi.IsLiteral && !fi.IsInitOnly)
.ToDictionary(x => (byte) x.GetValue(null)!, y => y.Name);
}
public static string FlagToString(byte flag)
{
return FlagCache[flag];
}
}
}
+1 -1
View File
@@ -59,7 +59,7 @@ namespace Impostor.Server.Net
{
var flag = reader.Tag;
_logger.LogTrace("[{0}] Server got {1}.", Id, flag);
_logger.LogTrace("[{0}] Server got {1}.", Id, MessageFlags.FlagToString(flag));
switch (flag)
{