From da79de5381999f5e01ac34dd245575d85d42cdd7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 6 Sep 2025 09:47:54 +0000 Subject: [PATCH] Add cfg to preclude log elision without requiring debug_assertions. Signed-off-by: Jason Volk --- docs/troubleshooting.md | 3 ++- src/core/debug.rs | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 6759c84a..eb203ed0 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -200,7 +200,8 @@ Various debug commands can be found in `!admin debug`. Tuwunel builds without debug or trace log levels at compile time by default for substantial performance gains in CPU usage and improved compile times. If you need to access debug/trace log levels, you will need to build without the -`release_max_log_level` feature or use our provided static debug binaries. +`release_max_log_level` feature or use our provided release-logging binaries +and images. #### Changing log level dynamically diff --git a/src/core/debug.rs b/src/core/debug.rs index 864279e0..c17c7806 100644 --- a/src/core/debug.rs +++ b/src/core/debug.rs @@ -114,6 +114,12 @@ pub fn rttype_name(_: &T) -> &'static str { type_name::() } #[must_use] pub fn type_name() -> &'static str { std::any::type_name::() } +/// Returns true if debug logging is enabled. In this mode extra logging calls +/// are made at all log levels, not just DEBUG and TRACE. These logs are demoted +/// to DEBUG level when this function returns false; as a consequence they will +/// be elided by `release_max_log_level` when featured. #[must_use] #[inline] -pub const fn logging() -> bool { cfg!(debug_assertions) } +pub const fn logging() -> bool { + cfg!(debug_assertions) || cfg!(tuwunel_debug) || cfg!(not(feature = "release_max_log_level")) +}