diff --git a/aya-log/README.md b/aya-log/README.md index aa94abb6..ee23c5e2 100644 --- a/aya-log/README.md +++ b/aya-log/README.md @@ -33,12 +33,12 @@ to log eBPF messages to the terminal. ### User space code ```rust -use aya_log::BpfLogger; +use aya_log::EbpfLogger; env_logger::init(); // Will log using the default logger, which is TermLogger in this case -BpfLogger::init(&mut bpf).unwrap(); +EbpfLogger::init(&mut bpf).unwrap(); ``` ### eBPF code diff --git a/aya-log/src/lib.rs b/aya-log/src/lib.rs index 2758ca7a..e533526d 100644 --- a/aya-log/src/lib.rs +++ b/aya-log/src/lib.rs @@ -3,7 +3,7 @@ //! This is the user space side of the [Aya] logging framework. For the eBPF //! side, see the `aya-log-ebpf` crate. //! -//! `aya-log` provides the [BpfLogger] type, which reads log records created by +//! `aya-log` provides the [EbpfLogger] type, which reads log records created by //! `aya-log-ebpf` and logs them using the [log] crate. Any logger that //! implements the [Log] trait can be used with this crate. //! @@ -13,13 +13,13 @@ //! //! ```no_run //! # let mut bpf = aya::Bpf::load(&[]).unwrap(); -//! use aya_log::BpfLogger; +//! use aya_log::EbpfLogger; //! //! // initialize env_logger as the default logger //! env_logger::init(); //! //! // start reading aya-log records and log them using the default logger -//! BpfLogger::init(&mut bpf).unwrap(); +//! EbpfLogger::init(&mut bpf).unwrap(); //! ``` //! //! With the following eBPF code: @@ -93,13 +93,17 @@ unsafe impl Pod for DisplayHintWrapper {} /// Log messages generated by `aya_log_ebpf` using the [log] crate. /// /// For more details see the [module level documentation](crate). -pub struct BpfLogger; +pub struct EbpfLogger; -impl BpfLogger { +/// Log messages generated by `aya_log_ebpf` using the [log] crate. +#[deprecated(since = "0.2.1", note = "Use `aya_log::EbpfLogger` instead")] +pub type BpfLogger = EbpfLogger; + +impl EbpfLogger { /// Starts reading log records created with `aya-log-ebpf` and logs them /// with the default logger. See [log::logger]. - pub fn init(bpf: &mut Bpf) -> Result { - BpfLogger::init_with_logger(bpf, log::logger()) + pub fn init(bpf: &mut Bpf) -> Result { + EbpfLogger::init_with_logger(bpf, log::logger()) } /// Starts reading log records created with `aya-log-ebpf` and logs them @@ -107,7 +111,7 @@ impl BpfLogger { pub fn init_with_logger( bpf: &mut Bpf, logger: T, - ) -> Result { + ) -> Result { let logger = Arc::new(logger); let mut logs: AsyncPerfEventArray<_> = bpf .take_map(MAP_NAME) @@ -131,7 +135,7 @@ impl BpfLogger { }); } - Ok(BpfLogger {}) + Ok(EbpfLogger {}) } } diff --git a/test/integration-test/src/tests/log.rs b/test/integration-test/src/tests/log.rs index c7980e0c..1f325851 100644 --- a/test/integration-test/src/tests/log.rs +++ b/test/integration-test/src/tests/log.rs @@ -4,7 +4,7 @@ use std::{ }; use aya::{programs::UProbe, Bpf}; -use aya_log::BpfLogger; +use aya_log::EbpfLogger; use log::{Level, Log, Record}; use test_log::test; @@ -45,7 +45,7 @@ async fn log() { let captured_logs = Arc::new(Mutex::new(Vec::new())); { let captured_logs = captured_logs.clone(); - BpfLogger::init_with_logger( + EbpfLogger::init_with_logger( &mut bpf, TestingLogger { log: move |record: &Record| {