add support for loglevel color configuration

This commit is contained in:
Master
2023-10-14 20:02:51 +02:00
parent 296bdd11e5
commit 21284c69c4
5 changed files with 33 additions and 29 deletions

View File

@@ -98,6 +98,7 @@ namespace AscNet.GameServer
public static void LoadPacketHandlers()
{
log.LogLevelColor[LogLevel.INFO] = ConsoleColor.White;
LoadRequestPacketHandlers();
}
@@ -111,7 +112,8 @@ namespace AscNet.GameServer
foreach (var method in classes.SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)))
{
var attr = method.GetCustomAttribute<RequestPacketHandler>(false);
if (attr == null || ReqHandlers.ContainsKey(attr.Name)) continue;
if (attr == null || ReqHandlers.ContainsKey(attr.Name))
continue;
ReqHandlers.Add(attr.Name, (RequestPacketHandlerDelegate)Delegate.CreateDelegate(typeof(RequestPacketHandlerDelegate), method));
#if DEBUG
log.Info($"Loaded {method.Name}");

View File

@@ -23,8 +23,8 @@ namespace AscNet.GameServer
this.id = id;
client = tcpClient;
// TODO: add session based configuration? maybe from database?
log = new(typeof(Session), LogLevel.DEBUG, LogLevel.DEBUG);
log = new(typeof(Session), id, LogLevel.DEBUG, LogLevel.DEBUG);
log.LogLevelColor[LogLevel.INFO] = ConsoleColor.Cyan;
Task.Run(ClientLoop);
}