Browse Source

feat(aya-log): Rename BpfLogger to EbpfLogger

Signed-off-by: Dave Tucker <[email protected]>
Dave Tucker 1 year ago
parent
commit
a93e354620
3 changed files with 17 additions and 13 deletions
  1. 2 2
      aya-log/README.md
  2. 13 9
      aya-log/src/lib.rs
  3. 2 2
      test/integration-test/src/tests/log.rs

+ 2 - 2
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

+ 13 - 9
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, Error> {
-        BpfLogger::init_with_logger(bpf, log::logger())
+    pub fn init(bpf: &mut Bpf) -> Result<EbpfLogger, Error> {
+        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<T: Log + 'static>(
         bpf: &mut Bpf,
         logger: T,
-    ) -> Result<BpfLogger, Error> {
+    ) -> Result<EbpfLogger, Error> {
         let logger = Arc::new(logger);
         let mut logs: AsyncPerfEventArray<_> = bpf
             .take_map(MAP_NAME)
@@ -131,7 +135,7 @@ impl BpfLogger {
             });
         }
 
-        Ok(BpfLogger {})
+        Ok(EbpfLogger {})
     }
 }
 

+ 2 - 2
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| {