rust/log: set the log level with a pure Rust function

Make sure the log level is setup with a pure Rust function, so
when it is set, its set within the address space of the caller.

This is important for Rust plugins where the Rust modules are not
in the address space of the Suricata main process.
pull/5356/head
Jason Ish 5 years ago committed by Victor Julien
parent 335e4e728f
commit 3de98b3595

@ -22,6 +22,7 @@ use std::path::Path;
use crate::core::*;
#[derive(Debug)]
#[repr(C)]
pub enum Level {
NotSet = -1,
None = 0,
@ -141,15 +142,15 @@ macro_rules!SCLogDebug {
#[no_mangle]
pub extern "C" fn rs_log_set_level(level: i32) {
log_set_level(level);
}
pub fn log_set_level(level: i32) {
unsafe {
LEVEL = level;
}
}
pub fn log_set_level(level: Level) {
rs_log_set_level(level as i32);
}
/// SCLogMessage wrapper. If the Suricata C context is not registered
/// a more basic log format will be used (for example, when running
/// Rust unit tests).

Loading…
Cancel
Save