diff options
| author | Mason Reed <mason@vector35.com> | 2025-12-19 19:15:38 -0500 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2026-01-11 10:36:01 -0800 |
| commit | 587a5c0c537a4b3bc5c737e3b3fc1fd5fbca3a59 (patch) | |
| tree | a01357f3a1ad00bdf6ebde29dfae673da2f78a57 /rust/examples/flowgraph.rs | |
| parent | 6f75ca031aa7e8f7e1c706d1880b202137b1996f (diff) | |
[Rust] Update examples to use tracing
Diffstat (limited to 'rust/examples/flowgraph.rs')
| -rw-r--r-- | rust/examples/flowgraph.rs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/rust/examples/flowgraph.rs b/rust/examples/flowgraph.rs index 75c854a7..cb03234e 100644 --- a/rust/examples/flowgraph.rs +++ b/rust/examples/flowgraph.rs @@ -6,6 +6,7 @@ use binaryninja::interaction::handler::{ register_interaction_handler, InteractionHandler, InteractionHandlerTask, }; use binaryninja::interaction::{MessageBoxButtonResult, MessageBoxButtonSet, MessageBoxIcon}; +use binaryninja::tracing::TracingLogListener; use binaryninja::{ architecture::BranchType, binary_view::{BinaryView, BinaryViewExt}, @@ -17,22 +18,22 @@ pub struct GraphPrinter; impl GraphPrinter { pub fn print_graph(&self, graph: &FlowGraph) { - println!("Printing flow graph:"); + tracing::info!("Printing flow graph:"); for node in &graph.nodes() { // Print all disassembly lines in the node - println!("Node @ {:?}:", node.position()); - println!("------------------"); - println!("Disassembly lines:"); + tracing::info!("Node @ {:?}:", node.position()); + tracing::info!("------------------"); + tracing::info!("Disassembly lines:"); for line in &node.lines() { - println!(" {}", line); + tracing::info!(" {}", line); } // Print outgoing edges - println!("Outgoing edges:"); + tracing::info!("Outgoing edges:"); for edge in &node.outgoing_edges() { - println!(" {:?} => {:?}", edge.branch_type, edge.target.position()); + tracing::info!(" {:?} => {:?}", edge.branch_type, edge.target.position()); } - println!("------------------"); + tracing::info!("------------------"); } } } @@ -62,14 +63,14 @@ impl InteractionHandler for GraphPrinter { } fn show_plain_text_report(&mut self, _view: Option<&BinaryView>, title: &str, contents: &str) { - println!("Plain text report"); - println!("Title: {}", title); - println!("Contents: {}", contents); + tracing::info!("Plain text report"); + tracing::info!("Title: {}", title); + tracing::info!("Contents: {}", contents); } fn show_graph_report(&mut self, _view: Option<&BinaryView>, title: &str, graph: &FlowGraph) { - println!("Graph report"); - println!("Title: {}", title); + tracing::info!("Graph report"); + tracing::info!("Title: {}", title); self.print_graph(graph); } @@ -115,12 +116,14 @@ fn test_graph() { } fn main() { - println!("Starting session..."); + tracing_subscriber::fmt::init(); + let _listener = TracingLogListener::new().register(); + // This loads all the core architecture, platform, etc plugins let headless_session = binaryninja::headless::Session::new().expect("Failed to initialize session"); - println!("Loading binary..."); + tracing::info!("Loading binary..."); let bv = headless_session .load("/bin/cat") .expect("Couldn't open `/bin/cat`"); |
