Skip to content

Commit

Permalink
fix bytes of packets not being logged in tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Dec 16, 2023
1 parent dc26558 commit 9260892
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions azalea-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ trust-dns-resolver = { version = "^0.23.2", default-features = false, features =
"tokio-runtime",
] }
uuid = "1.6.1"
log = "0.4.20"

[features]
connecting = []
Expand Down
5 changes: 2 additions & 3 deletions azalea-protocol/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use std::{
use thiserror::Error;
use tokio::io::AsyncRead;
use tokio_util::codec::{BytesCodec, FramedRead};
use tracing::if_log_enabled;

#[derive(Error, Debug)]
pub enum ReadPacketError {
Expand Down Expand Up @@ -348,7 +347,7 @@ where
.map_err(ReadPacketError::from)?;
}

if_log_enabled!(tracing::Level::TRACE, {
if log::log_enabled!(log::Level::Trace) {
let buf_string: String = {
if buf.len() > 500 {
let cut_off_buf = &buf[..500];
Expand All @@ -358,7 +357,7 @@ where
}
};
tracing::trace!("Reading packet with bytes: {buf_string}");
});
};

Ok(Some(buf))
}

0 comments on commit 9260892

Please sign in to comment.