Improved logging system.
This commit is contained in:
parent
d94b1cb813
commit
98d13ebbbb
24 changed files with 202 additions and 142 deletions
SharpChat/C2SPacketHandlers
|
@ -5,6 +5,7 @@ using SharpChat.Configuration;
|
|||
using SharpChat.Messages;
|
||||
using SharpChat.Snowflake;
|
||||
using SharpChat.SockChat.S2CPackets;
|
||||
using ZLogger;
|
||||
|
||||
namespace SharpChat.C2SPacketHandlers;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public class AuthC2SPacketHandler(
|
|||
|
||||
BanInfo? banInfo = await bansClient.BanGet(authResult.UserId, ctx.Connection.RemoteAddress);
|
||||
if(banInfo is not null) {
|
||||
Logger.Write($"<{ctx.Connection.Id}> User is banned.");
|
||||
ctx.Connection.Logger.ZLogInformation($"User {authResult.UserId} is banned.");
|
||||
await ctx.Connection.Send(new AuthFailS2CPacket(AuthFailS2CPacket.Reason.Banned, banInfo.IsPermanent ? DateTimeOffset.MaxValue : banInfo.ExpiresAt));
|
||||
ctx.Connection.Dispose();
|
||||
return;
|
||||
|
@ -139,12 +140,12 @@ public class AuthC2SPacketHandler(
|
|||
ctx.Chat.ContextAccess.Release();
|
||||
}
|
||||
} catch(AuthFailedException ex) {
|
||||
Logger.Write($"<{ctx.Connection.Id}> Failed to authenticate: {ex}");
|
||||
ctx.Connection.Logger.ZLogWarning($"Failed to authenticate (expected): {ex}");
|
||||
await ctx.Connection.Send(new AuthFailS2CPacket(AuthFailS2CPacket.Reason.AuthInvalid));
|
||||
ctx.Connection.Dispose();
|
||||
throw;
|
||||
} catch(Exception ex) {
|
||||
Logger.Write($"<{ctx.Connection.Id}> Failed to authenticate: {ex}");
|
||||
ctx.Connection.Logger.ZLogError($"Failed to authenticate (unexpected): {ex}");
|
||||
await ctx.Connection.Send(new AuthFailS2CPacket(AuthFailS2CPacket.Reason.Exception));
|
||||
ctx.Connection.Dispose();
|
||||
throw;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue