From: Jason Ish Date: Tue, 25 Aug 2020 18:50:31 +0000 (-0600) Subject: rust/log: set the log level with a pure Rust function X-Git-Tag: suricata-6.0.0-rc1~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3de98b35952c4623f1ff6e098deed2cc7abbbb93;p=thirdparty%2Fsuricata.git 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. --- 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).