From 3de98b35952c4623f1ff6e098deed2cc7abbbb93 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Tue, 25 Aug 2020 12:50:31 -0600 Subject: [PATCH] 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. --- rust/src/log.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rust/src/log.rs b/rust/src/log.rs index a7dcc73683..aeec3cbe8d 100644 --- a/rust/src/log.rs +++ b/rust/src/log.rs @@ -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).