summaryrefslogtreecommitdiff
path: root/rust/examples
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2024-11-11 17:05:44 -0500
committerMason Reed <mason@vector35.com>2024-11-11 17:05:44 -0500
commite856d391d377d0a723563925bb0a841ead5ae012 (patch)
tree197df92e0dfc44e1f1e243bf4b35cd08ef8c1cfd /rust/examples
parent911203528b5a5bfc7a98e86ad55b80f7a1385969 (diff)
Add actual logger api to rust
Diffstat (limited to 'rust/examples')
-rw-r--r--rust/examples/dwarf/dwarf_export/src/lib.rs4
-rw-r--r--rust/examples/dwarf/dwarf_import/src/lib.rs4
-rw-r--r--rust/examples/idb_import/src/lib.rs3
-rw-r--r--rust/examples/minidump/src/lib.rs3
-rw-r--r--rust/examples/pdb-ng/src/lib.rs5
-rw-r--r--rust/examples/test_demangler/src/lib.rs3
-rw-r--r--rust/examples/workflow/src/lib.rs3
7 files changed, 15 insertions, 10 deletions
diff --git a/rust/examples/dwarf/dwarf_export/src/lib.rs b/rust/examples/dwarf/dwarf_export/src/lib.rs
index 05592f5f..18cc1e21 100644
--- a/rust/examples/dwarf/dwarf_export/src/lib.rs
+++ b/rust/examples/dwarf/dwarf_export/src/lib.rs
@@ -15,13 +15,13 @@ use binaryninja::{
command::{register, Command},
interaction,
interaction::{FormResponses, FormResponses::Index},
- logger::init,
rc::Ref,
string::BnString,
symbol::SymbolType,
types::{Conf, MemberAccess, StructureType, Type, TypeClass},
};
use log::{error, info, LevelFilter};
+use binaryninja::logger::Logger;
fn export_type(
name: String,
@@ -781,7 +781,7 @@ impl Command for MyCommand {
#[no_mangle]
pub extern "C" fn CorePluginInit() -> bool {
- init(LevelFilter::Debug);
+ Logger::new("DWARF Export").with_level(LevelFilter::Debug).init();
register(
"Export as DWARF",
diff --git a/rust/examples/dwarf/dwarf_import/src/lib.rs b/rust/examples/dwarf/dwarf_import/src/lib.rs
index 20076d0c..b0617ee3 100644
--- a/rust/examples/dwarf/dwarf_import/src/lib.rs
+++ b/rust/examples/dwarf/dwarf_import/src/lib.rs
@@ -42,7 +42,7 @@ use gimli::{constants, CfaRule, DebuggingInformationEntry, Dwarf, DwarfFileType,
use helpers::{get_build_id, load_debug_info_for_build_id};
use log::{debug, error, warn, LevelFilter};
-
+use binaryninja::logger::Logger;
trait ReaderType: Reader<Offset = usize> {}
impl<T: Reader<Offset = usize>> ReaderType for T {}
@@ -658,7 +658,7 @@ impl CustomDebugInfoParser for DWARFParser {
#[no_mangle]
pub extern "C" fn CorePluginInit() -> bool {
- logger::init(LevelFilter::Debug);
+ Logger::new("DWARF").init();
let settings = Settings::new("");
diff --git a/rust/examples/idb_import/src/lib.rs b/rust/examples/idb_import/src/lib.rs
index 0de688be..1faf188c 100644
--- a/rust/examples/idb_import/src/lib.rs
+++ b/rust/examples/idb_import/src/lib.rs
@@ -16,6 +16,7 @@ use idb_rs::til::Type as TILType;
use log::{error, trace, warn, LevelFilter};
use anyhow::Result;
+use binaryninja::logger::Logger;
struct IDBDebugInfoParser;
impl CustomDebugInfoParser for IDBDebugInfoParser {
@@ -337,7 +338,7 @@ fn parse_id0_section_info(
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn CorePluginInit() -> bool {
- logger::init(LevelFilter::Error);
+ Logger::new("IDB Import").with_level(LevelFilter::Error).init();
DebugInfoParser::register("IDB Parser", IDBDebugInfoParser);
DebugInfoParser::register("TIL Parser", TILDebugInfoParser);
true
diff --git a/rust/examples/minidump/src/lib.rs b/rust/examples/minidump/src/lib.rs
index c899591b..62898301 100644
--- a/rust/examples/minidump/src/lib.rs
+++ b/rust/examples/minidump/src/lib.rs
@@ -2,6 +2,7 @@ use binaryninja::binaryview::BinaryView;
use binaryninja::command::{register, Command};
use binaryninja::custombinaryview::register_view_type;
use log::{debug, LevelFilter};
+use binaryninja::logger::Logger;
mod command;
mod view;
@@ -21,7 +22,7 @@ impl Command for PrintMemoryInformationCommand {
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
- binaryninja::logger::init(LevelFilter::Trace);
+ Logger::new("Minidump").with_level(LevelFilter::Trace).init();
debug!("Registering minidump binary view type");
register_view_type("Minidump", "Minidump", view::MinidumpBinaryViewType::new);
diff --git a/rust/examples/pdb-ng/src/lib.rs b/rust/examples/pdb-ng/src/lib.rs
index bc12caae..47eed6ea 100644
--- a/rust/examples/pdb-ng/src/lib.rs
+++ b/rust/examples/pdb-ng/src/lib.rs
@@ -21,7 +21,7 @@ use std::sync::mpsc;
use std::{env, fs};
use anyhow::{anyhow, Result};
-use log::{debug, error, info, LevelFilter};
+use log::{debug, error, info};
use pdb::PDB;
use binaryninja::binaryview::{BinaryView, BinaryViewBase, BinaryViewExt};
@@ -31,6 +31,7 @@ use binaryninja::interaction::{MessageBoxButtonResult, MessageBoxButtonSet};
use binaryninja::settings::Settings;
use binaryninja::string::BnString;
use binaryninja::{add_optional_plugin_dependency, interaction, logger, user_directory};
+use binaryninja::logger::Logger;
use parser::PDBParserInstance;
/// PDB Parser!!
@@ -697,7 +698,7 @@ pub extern "C" fn PDBPluginInit() -> bool {
}
fn init_plugin() -> bool {
- logger::init(LevelFilter::Debug);
+ Logger::new("PDB").init();
DebugInfoParser::register("PDB", PDBParser {});
let settings = Settings::new("");
diff --git a/rust/examples/test_demangler/src/lib.rs b/rust/examples/test_demangler/src/lib.rs
index 6735d5fb..d7dc9eec 100644
--- a/rust/examples/test_demangler/src/lib.rs
+++ b/rust/examples/test_demangler/src/lib.rs
@@ -4,6 +4,7 @@ use binaryninja::binaryview::BinaryView;
use binaryninja::{command, logger};
use binaryninja::command::Command;
use binaryninja::demangle::{Demangler, CustomDemangler};
+use binaryninja::logger::Logger;
use binaryninja::rc::Ref;
use binaryninja::types::{QualifiedName, Type};
@@ -57,7 +58,7 @@ impl Command for DemangleCommand {
#[no_mangle]
pub extern "C" fn CorePluginInit() -> bool {
- logger::init(LevelFilter::Info);
+ Logger::new("Demangle Test").with_level(LevelFilter::Info).init();
Demangler::register("Test", TestDemangler {});
command::register("Demangle Test", "Test", DemangleCommand {});
true
diff --git a/rust/examples/workflow/src/lib.rs b/rust/examples/workflow/src/lib.rs
index 47a8d2c8..6f415941 100644
--- a/rust/examples/workflow/src/lib.rs
+++ b/rust/examples/workflow/src/lib.rs
@@ -3,6 +3,7 @@ use binaryninja::llil::{
};
use binaryninja::workflow::{Activity, AnalysisContext, Workflow};
use log::LevelFilter;
+use binaryninja::logger::Logger;
const RUST_ACTIVITY_NAME: &'static str = "analysis.plugins.rustexample";
const RUST_ACTIVITY_CONFIG: &'static str = r#"{
@@ -55,7 +56,7 @@ fn example_activity(analysis_context: &AnalysisContext) {
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
- binaryninja::logger::init(LevelFilter::Info);
+ Logger::new("Workflow Example").with_level(LevelFilter::Info).init();
log::info!("Initialized the plugin");