pub struct TracingLogListener { /* private fields */ }Expand description
A LogListener that forwards logs to the registered [Subscriber].
This should never be registered if the BinaryNinjaLayer is active. The BinaryNinjaLayer
will consume our events we send in this log listener and send them back to the core, causing a
never-ending cycle of sending and receiving the same logs.
Typically, you will register this listener for headless applications. You can technically use this in a plugin, but it is likely that you are sending tracing logs to the core, in which case you will run into the problem above.
use binaryninja::tracing::TracingLogListener;
use binaryninja::logger::{register_log_listener, BnLogLevel, bn_log};
use binaryninja::headless::Session;
pub fn main() {
// Register our tracing subscriber, this will send tracing events to stdout.
tracing_subscriber::fmt::init();
// Register our log listener, this will send logs from the core to our tracing subscriber.
let _listener = TracingLogListener::new().register();
// Should see logs from the core in regard to initialization show up.
let _session = Session::new().expect("Failed to create session");
bn_log("Test", BnLogLevel::DebugLog, "Hello, world!");
}Implementations§
Source§impl TracingLogListener
impl TracingLogListener
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a TracingLogListener with the minimum log level set to BnLogLevel::InfoLog.
pub fn new_with_lvl(minimum_level: BnLogLevel) -> Self
Sourcepub fn register(self) -> LogGuard<Self>
pub fn register(self) -> LogGuard<Self>
Register the TracingLogListener and send logs to the registered tracing subscriber until
the LogGuard is dropped, make sure to register your tracing subscriber before registering.
Trait Implementations§
Source§impl Default for TracingLogListener
impl Default for TracingLogListener
Source§impl LogListener for TracingLogListener
impl LogListener for TracingLogListener
Source§fn log(&self, ctx: &LogContext<'_>, level: BnLogLevel, message: &str)
fn log(&self, ctx: &LogContext<'_>, level: BnLogLevel, message: &str)
Source§fn level(&self) -> BnLogLevel
fn level(&self) -> BnLogLevel
Auto Trait Implementations§
impl Freeze for TracingLogListener
impl RefUnwindSafe for TracingLogListener
impl Send for TracingLogListener
impl Sync for TracingLogListener
impl Unpin for TracingLogListener
impl UnwindSafe for TracingLogListener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more