aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUbuntu <github@matdoes.dev>2022-09-09 19:42:35 +0000
committerUbuntu <github@matdoes.dev>2022-09-09 19:42:35 +0000
commit2889514307098aa185f18e62a349c49581ef45f0 (patch)
treee1191802b241d6b6b38b70ee47bbedcdf106c5f3
parentc033587503eedc822cd3c9d44bf60a6dc51f8263 (diff)
downloadazalea-drasl-2889514307098aa185f18e62a349c49581ef45f0.tar.xz
improve log
-rwxr-xr-xazalea-protocol/src/read.rs14
1 files 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())?;