add debug log for request

This commit is contained in:
rfi 2023-10-14 22:01:49 +07:00
parent fbf0a6d3ba
commit 59efd63930
2 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,6 @@
using System.Buffers.Binary;
using System.Net.Sockets;
using AscNet.Common;
using AscNet.Common.Util;
using MessagePack;
using Newtonsoft.Json;
@ -80,11 +81,15 @@ namespace AscNet.GameServer
RequestPacketHandlerDelegate? requestPacketHandler = PacketFactory.GetRequestPacketHandler(request.Name);
if (requestPacketHandler is not null)
{
c.Log(request.Name);
if (Common.Common.config.VerboseLevel > VerboseLevel.Silent)
c.Log($"{request.Name}{(Common.Common.config.VerboseLevel >= VerboseLevel.Debug ? (", " + JsonConvert.SerializeObject(MessagePackSerializer.Typeless.Deserialize(request.Content))) : "")}");
requestPacketHandler.Invoke(this, request);
}
else
c.Warn($"{request.Name} handler not found!");
{
if (Common.Common.config.VerboseLevel > VerboseLevel.Silent)
c.Warn($"{request.Name} handler not found!{(Common.Common.config.VerboseLevel >= VerboseLevel.Debug ? (", " + JsonConvert.SerializeObject(MessagePackSerializer.Typeless.Deserialize(request.Content))) : "")}");
}
break;
case Packet.ContentType.Push:
Packet.Push push = MessagePackSerializer.Deserialize<Packet.Push>(packet.Content);

View File

@ -8,6 +8,12 @@ namespace AscNet
static void Main(string[] args)
{
Logger.c.Log("Starting...");
#if DEBUG
if (Common.Common.config.VerboseLevel < Common.VerboseLevel.Debug)
Common.Common.config.VerboseLevel = Common.VerboseLevel.Debug;
#endif
PacketFactory.LoadPacketHandlers();
Task.Run(GameServer.Server.Instance.Start);
SDKServer.SDKServer.Main(args);