Skip to content

Commit 1aef9ad

Browse files
committed
fix: eliminate debug log code generation without debug feature in nginx
1 parent 5890854 commit 1aef9ad

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/log.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ use core::ptr::NonNull;
55

66
use crate::ffi::{self, ngx_err_t, ngx_log_t, ngx_uint_t, NGX_MAX_ERROR_STR};
77

8+
/// This constant is TRUE if NGINX is compiled with debug logging (--with-debug).
9+
pub const DEBUG: bool = cfg!(ngx_feature = "debug");
10+
811
/// Size of the static buffer used to format log messages.
912
///
1013
/// 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 {
132135
macro_rules! ngx_log_debug {
133136
( mask: $mask:expr, $log:expr, $($arg:tt)+ ) => {
134137
let log = $log;
135-
if $crate::log::check_mask($mask, unsafe { (*log).log_level }) {
138+
if $crate::log::DEBUG && $crate::log::check_mask($mask, unsafe { (*log).log_level }) {
136139
let mut buf =
137140
[const { ::core::mem::MaybeUninit::<u8>::uninit() }; $crate::log::LOG_BUFFER_SIZE];
138141
let message = $crate::log::write_fmt(&mut buf, format_args!($($arg)+));

0 commit comments

Comments
 (0)