From 168a3fd34824adc9c6a606cd144219701f15cccf Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 17 Dec 2025 21:23:46 -0500 Subject: [Rust] Replace `log` with `tracing` - Added more documentation - Replaced global named logger for plugins, fixing the issue when the CU has multiple (e.g. statically linked demo) - Simplified some misc code This is a breaking change, but I believe there is no better time to make it, we cannot continue to use the `log` crate, it is too limited for our needs. --- rust/src/low_level_il/expression.rs | 3 +-- rust/src/low_level_il/lifting.rs | 6 +++--- rust/src/low_level_il/operation.rs | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'rust/src/low_level_il') diff --git a/rust/src/low_level_il/expression.rs b/rust/src/low_level_il/expression.rs index 1e4ab21b..8103518c 100644 --- a/rust/src/low_level_il/expression.rs +++ b/rust/src/low_level_il/expression.rs @@ -536,8 +536,7 @@ where } _ => { - // #[cfg(debug_assertions)] - log::error!( + tracing::error!( "Got unexpected operation {:?} in value expr at 0x{:x}", op.operation, op.address diff --git a/rust/src/low_level_il/lifting.rs b/rust/src/low_level_il/lifting.rs index bab0906c..d162b3f6 100644 --- a/rust/src/low_level_il/lifting.rs +++ b/rust/src/low_level_il/lifting.rs @@ -533,7 +533,7 @@ macro_rules! prim_int_lifter { }; if !is_safe { - log::error!("il @ {:x} attempted to lift constant 0x{:x} as {} byte expr (won't fit!)", + tracing::error!("il @ {:x} attempted to lift constant 0x{:x} as {} byte expr (won't fit!)", il.current_address(), val, size); } } @@ -660,7 +660,7 @@ impl<'a> LiftableLowLevelILWithSize<'a> for LowLevelILExpression<'a, Mutable, No use crate::low_level_il::ExpressionHandler; if let Some(expr_size) = expr.kind().size() { if expr_size != _size { - log::warn!( + tracing::warn!( "il @ {:x} attempted to lift {} byte expression as {} bytes", il.current_address(), expr_size, @@ -788,7 +788,7 @@ impl<'a> LiftableLowLevelILWithSize<'a> for ExpressionBuilder<'a, ValueExpr> { use binaryninjacore_sys::BNLowLevelILOperation::{LLIL_UNIMPL, LLIL_UNIMPL_MEM}; if expr.size != _size && ![LLIL_UNIMPL, LLIL_UNIMPL_MEM].contains(&expr.op) { - log::warn!( + tracing::warn!( "il @ {:x} attempted to lift {} byte expression builder as {} bytes", il.current_address(), expr.size, diff --git a/rust/src/low_level_il/operation.rs b/rust/src/low_level_il/operation.rs index f8bbc3c6..8f94b74f 100644 --- a/rust/src/low_level_il/operation.rs +++ b/rust/src/low_level_il/operation.rs @@ -1745,7 +1745,7 @@ where }; if !is_safe { - log::error!( + tracing::error!( "il expr @ {:x} contains constant 0x{:x} as {} byte value (doesn't fit!)", self.op.address, self.op.operands[0], @@ -1810,7 +1810,7 @@ where } _ => { // Log error for unexpected sizes - log::error!( + tracing::error!( "il expr @ {:x} has invalid float size {} (expected 4 or 8 bytes)", self.op.address, self.op.size @@ -1858,7 +1858,7 @@ where }; if !is_safe { - log::error!( + tracing::error!( "il expr @ {:x} contains extern 0x{:x} as {} byte value (doesn't fit!)", self.op.address, self.op.operands[0], -- cgit v1.3.1