diff --git a/rust/Cargo.toml.in b/rust/Cargo.toml.in index 1a0384cddc..9cd079f7a2 100644 --- a/rust/Cargo.toml.in +++ b/rust/Cargo.toml.in @@ -12,6 +12,7 @@ debug = true lua = [] experimental = ["ntp-parser"] strict = [] +debug = [] [dependencies] nom = "~3.2.1" diff --git a/rust/Makefile.am b/rust/Makefile.am index 776d86b77a..6bc8a7b018 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -29,6 +29,10 @@ if HAVE_RUST_EXTERNAL RUST_FEATURES += experimental endif +if DEBUG +RUST_FEATURES += debug +endif + all-local: if HAVE_PYTHON cd $(top_srcdir)/rust && \ diff --git a/rust/src/log.rs b/rust/src/log.rs index 018888ca5f..bdc4cc0e09 100644 --- a/rust/src/log.rs +++ b/rust/src/log.rs @@ -114,6 +114,8 @@ macro_rules!SCLogConfig { } } +// Debug mode: call C SCLogDebug +#[cfg(feature = "debug")] #[macro_export] macro_rules!SCLogDebug { ($($arg:tt)*) => { @@ -121,6 +123,15 @@ macro_rules!SCLogDebug { } } +// Release mode: ignore arguments +// Use a reference to avoid moving values. +#[cfg(not(feature = "debug"))] +#[macro_export] +macro_rules!SCLogDebug { + ($last:expr) => { let _ = &$last; let _ = Level::Debug; }; + ($one:expr, $($arg:tt)*) => { let _ = &$one; SCLogDebug!($($arg)*); }; +} + #[no_mangle] pub extern "C" fn rs_log_set_level(level: i32) { unsafe {