From 2889514307098aa185f18e62a349c49581ef45f0 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 9 Sep 2022 19:42:35 +0000 Subject: improve log --- azalea-protocol/src/read.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index f7c783de..1ed491af 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -3,7 +3,7 @@ use azalea_buf::McBufVarReadable; use azalea_buf::{read_varint_async, BufReadError}; use azalea_crypto::Aes128CfbDec; use flate2::read::ZlibDecoder; -use log::trace; +use log::{log_enabled, trace}; use std::{ cell::Cell, io::Read, @@ -201,7 +201,17 @@ where buf = compression_decoder(&mut buf.as_slice(), compression_threshold)?; } - trace!("Reading packet with bytes: {buf:?}"); + if log_enabled!(log::Level::Trace) { + let buf_string: String = { + if buf.len() > 100 { + let cut_off_buf = &buf[..100]; + format!("{cut_off_buf:?}...") + } else { + format!("{buf:?}") + } + }; + trace!("Reading packet with bytes: {buf_string}"); + } let packet = packet_decoder(&mut buf.as_slice())?; -- cgit v1.2.3