Add cfg to preclude log elision without requiring debug_assertions.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-09-06 09:47:54 +00:00
parent 1bcf3ae19a
commit da79de5381
2 changed files with 9 additions and 2 deletions

View File

@@ -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 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 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 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 #### Changing log level dynamically

View File

@@ -114,6 +114,12 @@ pub fn rttype_name<T: ?Sized>(_: &T) -> &'static str { type_name::<T>() }
#[must_use] #[must_use]
pub fn type_name<T: ?Sized>() -> &'static str { std::any::type_name::<T>() } pub fn type_name<T: ?Sized>() -> &'static str { std::any::type_name::<T>() }
/// 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] #[must_use]
#[inline] #[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"))
}