From 23a22e3adf829936119543aa160bc081f1c404f6 Mon Sep 17 00:00:00 2001 From: alemidev Date: Sat, 11 Dec 2021 05:59:51 +0100 Subject: [PATCH] better debug logging --- aiocraft/client.py | 2 +- aiocraft/dispatcher.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/aiocraft/client.py b/aiocraft/client.py index 2fce64f..12f54eb 100644 --- a/aiocraft/client.py +++ b/aiocraft/client.py @@ -268,7 +268,7 @@ class MinecraftClient(CallbacksHolder, Runnable): self.dispatcher.state = ConnectionState.PLAY self.run_callbacks(ClientEvent.CONNECTED) async for packet in self.dispatcher.packets(): - self._logger.debug("[ * ] Processing | %s", str(packet)) + self._logger.debug("[ * ] Processing %s", packet.__class__.__name__) if isinstance(packet, PacketSetCompression): self._logger.info("Compression updated") self.dispatcher.compression = packet.threshold diff --git a/aiocraft/dispatcher.py b/aiocraft/dispatcher.py index 86f5c80..40bea93 100644 --- a/aiocraft/dispatcher.py +++ b/aiocraft/dispatcher.py @@ -199,7 +199,6 @@ class Dispatcher: async def _down_worker(self, timeout:float=30): while self._dispatching: try: # these 2 will timeout or raise EOFError if client gets disconnected - self._logger.debug("Reading packet") data = await asyncio.wait_for(self._read_packet(), timeout=timeout) if self.encryption: @@ -220,9 +219,8 @@ class Dispatcher: if packet_id in BROKEN_PACKETS: continue # cheap fix, still need to implement NBT, Slot and EntityMetadata... cls = self._packet_type_from_registry(packet_id) - self._logger.debug("Deserializing packet %s | %s", str(cls), cls._state) packet = cls.deserialize(self.proto, buffer) - self._logger.debug("[<--] Received | %s", str(packet)) + self._logger.debug("[<--] Received | %s", repr(packet)) await self._incoming.put(packet) if self.state != ConnectionState.PLAY: await self._incoming.join() # During play we can pre-process packets @@ -236,7 +234,8 @@ class Dispatcher: self._logger.error("Received EOF while reading packet") await self.disconnect(block=False) except Exception: - self._logger.exception("Exception parsing packet %d | %s", packet_id, buffer.getvalue()) + self._logger.exception("Exception parsing packet %d", packet_id) + self._logger.debug("%s", buffer.getvalue()) await self.disconnect(block=False) async def _up_worker(self, timeout=1): @@ -270,7 +269,7 @@ class Dispatcher: self._up.write(data) await self._up.drain() - self._logger.debug("[-->] Sent | %s", str(packet)) + self._logger.debug("[-->] Sent | %s", repr(packet)) except Exception: self._logger.exception("Exception dispatching packet %s", str(packet))