From 2dcff0cf4562b2839faf82df134ce25233bf3f21 Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 14 Jun 2022 11:22:04 +0100 Subject: [PATCH] Reduce unnecessary logs from packetLogger --- .../src/commonMain/kotlin/network/components/PacketCodec.kt | 4 +++- .../kotlin/network/impl/netty/NettyNetworkHandler.kt | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt b/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt index bb1316823..eb174577c 100644 --- a/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt +++ b/mirai-core/src/commonMain/kotlin/network/components/PacketCodec.kt @@ -195,7 +195,9 @@ internal class PacketCodecImpl : PacketCodec { if (PacketLogger.isEnabled) { val extraData = readBytes(readInt() - 4) - PacketLogger.verbose { "(sso/inner)extraData = ${extraData.toUHexString()}" } + if (extraData.isNotEmpty()) { + PacketLogger.verbose { "(sso/inner)extraData = ${extraData.toUHexString()}" } + } } else { discardExact(readInt() - 4) } diff --git a/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt b/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt index d4aa8b9f7..96431a04a 100644 --- a/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt +++ b/mirai-core/src/commonMain/kotlin/network/impl/netty/NettyNetworkHandler.kt @@ -110,7 +110,6 @@ internal open class NettyNetworkHandler( private inner class OutgoingPacketEncoder : MessageToByteEncoder(OutgoingPacket::class.java) { override fun encode(ctx: ChannelHandlerContext, msg: OutgoingPacket, out: ByteBuf) { - packetLogger.debug { "encode: ${msg.displayName}" } out.writeBytes(msg.delegate) } } @@ -187,7 +186,6 @@ internal open class NettyNetworkHandler( fun send(raw: RawIncomingPacket) { launch { - packetLogger.debug { "Packet Handling Processor: receive packet ${raw.commandName}" } val result = packetCodec.processBody(context.bot, raw) if (result == null) { collectUnknownPacket(raw)