Skip to content

Commit

Permalink
add AZALEA_DO_NOT_CUT_OFF_PACKET_LOGS env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Jan 12, 2025
1 parent 608ccb8 commit 093c99a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions azalea-protocol/src/read.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Read packets from a stream.
use std::backtrace::Backtrace;
use std::env;
use std::sync::LazyLock;
use std::{
fmt::Debug,
io::{Cursor, Read},
Expand Down Expand Up @@ -367,10 +369,14 @@ where
}

if tracing::enabled!(tracing::Level::TRACE) {
const DO_NOT_CUT_OFF_PACKET_LOGS: bool = false;
static DO_NOT_CUT_OFF_PACKET_LOGS: LazyLock<bool> = LazyLock::new(|| {
env::var("AZALEA_DO_NOT_CUT_OFF_PACKET_LOGS")
.map(|s| s == "1" || s == "true")
.unwrap_or(false)
});

let buf_string: String = {
if !DO_NOT_CUT_OFF_PACKET_LOGS && buf.len() > 500 {
if !*DO_NOT_CUT_OFF_PACKET_LOGS && buf.len() > 500 {
let cut_off_buf = &buf[..500];
format!("{cut_off_buf:?}...")
} else {
Expand Down

0 comments on commit 093c99a

Please sign in to comment.