|
1 | | -// TODO: Add top level docs here. |
| 1 | +//! Integration with the [`tracing`](https://docs.rs/tracing) ecosystem. Send logs to and from Binary Ninja. |
| 2 | +//! |
| 3 | +//! This module allows you to use standard Rust `tracing` macros (like `info!`, `warn!`, `error!`) |
| 4 | +//! and have them get sent to Binary Ninja, as well as the other way around with [`TracingLogListener`]. |
| 5 | +//! |
| 6 | +//! ## For Plugins |
| 7 | +//! |
| 8 | +//! When writing a plugin, and you want your Rust logs to appear in the Binary Ninja UI, use the |
| 9 | +//! [`crate::tracing_init`] macro at the start of your plugin's init function. |
| 10 | +//! |
| 11 | +//! ## For Headless |
| 12 | +//! |
| 13 | +//! When running headless (standalone executables), and you want internal Binary Ninja logs to appear |
| 14 | +//! in your terminal's standard output, register the [`TracingLogListener`] after initializing your |
| 15 | +//! tracing subscriber. |
| 16 | +//! |
| 17 | +//! ## Never use both [`BinaryNinjaLayer`] and [`TracingLogListener`] simultaneously |
| 18 | +//! |
| 19 | +//! Enabling both creates an infinite feedback loop where a log triggers a log, deadlocking the application. |
2 | 20 |
|
3 | 21 | use crate::file_metadata::SessionId; |
4 | 22 | use crate::logger::{ |
@@ -259,7 +277,7 @@ impl tracing::field::Visit for BnFieldVisitor { |
259 | 277 | /// // Register our tracing subscriber, this will send tracing events to stdout. |
260 | 278 | /// tracing_subscriber::fmt::init(); |
261 | 279 | /// // Register our log listener, this will send logs from the core to our tracing subscriber. |
262 | | -/// let _listener = TracingLogListener::new(BnLogLevel::DebugLog).register(); |
| 280 | +/// let _listener = TracingLogListener::new().register(); |
263 | 281 | /// // Should see logs from the core in regard to initialization show up. |
264 | 282 | /// let _session = Session::new().expect("Failed to create session"); |
265 | 283 | /// bn_log("Test", BnLogLevel::DebugLog, "Hello, world!"); |
|
0 commit comments