From 27d27dd4ca57127fc4012089a04abebd953e44bd Mon Sep 17 00:00:00 2001 From: Evgeny Shirykalov Date: Thu, 7 Aug 2025 17:17:48 -0700 Subject: [PATCH] fix: eliminate debug log code generation without debug feature in nginx --- src/log.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/log.rs b/src/log.rs index e257b71a..47b496eb 100644 --- a/src/log.rs +++ b/src/log.rs @@ -5,6 +5,9 @@ use core::ptr::NonNull; use crate::ffi::{self, ngx_err_t, ngx_log_t, ngx_uint_t, NGX_MAX_ERROR_STR}; +/// This constant is set to `true` if NGINX is compiled with debug logging (`--with-debug`). +pub const DEBUG: bool = cfg!(ngx_feature = "debug"); + /// Size of the static buffer used to format log messages. /// /// Approximates the remaining space in `u_char[NGX_MAX_ERROR_STR]` after writing the standard @@ -132,7 +135,7 @@ macro_rules! ngx_conf_log_error { macro_rules! ngx_log_debug { ( mask: $mask:expr, $log:expr, $($arg:tt)+ ) => { let log = $log; - if $crate::log::check_mask($mask, unsafe { (*log).log_level }) { + if $crate::log::DEBUG && $crate::log::check_mask($mask, unsafe { (*log).log_level }) { let mut buf = [const { ::core::mem::MaybeUninit::::uninit() }; $crate::log::LOG_BUFFER_SIZE]; let message = $crate::log::write_fmt(&mut buf, format_args!($($arg)+));