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.