From 62f2dd7c6c89ca44f2096f535962b63f26f57730 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sat, 19 Oct 2024 20:53:10 -0400 Subject: Remove ability to panic on pre-initialized logger in rust Typically this would never occur, however due to the mystical nature of linkers this somehow has happened outside of demo builds --- rust/src/logger.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'rust/src') diff --git a/rust/src/logger.rs b/rust/src/logger.rs index 6e0b1887..4e9dd1f9 100644 --- a/rust/src/logger.rs +++ b/rust/src/logger.rs @@ -75,11 +75,13 @@ impl log::Log for Logger { fn flush(&self) {} } -/// Uses BinaryNinja's logging functionality as the sink for -/// Rust's `log` crate. -pub fn init(filter: log::LevelFilter) -> Result<(), log::SetLoggerError> { +/// Uses BinaryNinja's logging functionality as the sink for Rust's `log` crate. +/// +/// NOTE: There is no guarantee that logs will be sent to BinaryNinja as another log sink +/// may have already been initialized beforehand. +pub fn init(filter: log::LevelFilter) { log::set_max_level(filter); - log::set_logger(&LOGGER) + let _ = log::set_logger(&LOGGER); } pub trait LogListener: 'static + Sync { -- cgit v1.3.1