mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Gate empty-packet log under debug, add packet exclusion list
- Change empty packet log from log.Warn to log.Debug so it only shows when DebugMessages is enabled - Add PacketDebugExclusions config (List<string>) to suppress specific packet types like KeepAlive, Ping from packet debug output - Check exclusion in both LogIncomingPacket and LogOutgoingPacket - Add ConfigComments resource entry for the new setting
This commit is contained in:
parent
28e845d1ca
commit
98dfde6cc2
4 changed files with 30 additions and 2 deletions
|
|
@ -443,7 +443,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (packetData.Count == 0)
|
||||
{
|
||||
var rawHex = rawBytes.Length > 0 ? BitConverter.ToString(rawBytes).Replace("-", " ") : "(empty)";
|
||||
log.Warn($"[DEBUG] Empty packet after decompress: size={size}, sizeUncompressed={sizeUncompressed}, protocol={protocolVersion}, state={currentState}, rawBytes=[{rawHex}]");
|
||||
log.Debug("Empty packet after decompress: size={0}, sizeUncompressed={1}, protocol={2}, state={3}, rawBytes=[{4}]", size, sizeUncompressed, protocolVersion, currentState, rawHex);
|
||||
return new(-1, packetData);
|
||||
}
|
||||
|
||||
|
|
@ -4158,12 +4158,21 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
log.PacketDebug(string.Format(Translations.debug_packet_state_change, previousState, newState));
|
||||
}
|
||||
|
||||
private static bool IsPacketExcluded(string packetType)
|
||||
{
|
||||
var exclusions = Settings.Config.Logging.PacketDebugExclusions;
|
||||
return exclusions.Count > 0 && exclusions.Contains(packetType, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private void LogIncomingPacket(int packetId, int payloadLength, int frameLength, bool compressed, int uncompressedLength)
|
||||
{
|
||||
if (!log.DebugEnabled)
|
||||
return;
|
||||
|
||||
var packetType = ResolveIncomingPacketType(packetId);
|
||||
if (IsPacketExcluded(packetType))
|
||||
return;
|
||||
|
||||
var compressionInfo = compression_treshold < 0
|
||||
? Translations.debug_packet_compression_disabled
|
||||
: compressed
|
||||
|
|
@ -4184,10 +4193,14 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (!log.DebugEnabled)
|
||||
return;
|
||||
|
||||
var resolvedType = packetType ?? ResolveOutgoingPacketType(packetId);
|
||||
if (IsPacketExcluded(resolvedType))
|
||||
return;
|
||||
|
||||
log.PacketDebug(string.Format(Translations.debug_packet_outgoing,
|
||||
currentState,
|
||||
packetId,
|
||||
packetType ?? ResolveOutgoingPacketType(packetId),
|
||||
resolvedType,
|
||||
payloadLength,
|
||||
compression_treshold));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue