Rust: add 'debug' feature

The 'debug' feature is enabled if suricata was configured with the
--enabled-debug' flag.
If enabled, the SCLogDebug format and calls the logging function as
usual. Otherwise, this macro is a no-op (similarly to the C code).
pull/3272/head
Pierre Chifflier 7 years ago committed by Victor Julien
parent 04e87e1a9f
commit b69acaadf5

@ -12,6 +12,7 @@ debug = true
lua = []
experimental = ["ntp-parser"]
strict = []
debug = []
[dependencies]
nom = "~3.2.1"

@ -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 && \

@ -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 {

Loading…
Cancel
Save