Browse Source

Remove pointless DefaultLogger

This avoids an atomic load on every log.
Tamir Duberstein 1 year ago
parent
commit
00d265c51b
1 changed files with 1 additions and 18 deletions
  1. 1 18
      aya-log/src/lib.rs

+ 1 - 18
aya-log/src/lib.rs

@@ -98,7 +98,7 @@ impl BpfLogger {
     /// 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, DefaultLogger {})
+        BpfLogger::init_with_logger(bpf, log::logger())
     }
 
     /// Starts reading log records created with `aya-log-ebpf` and logs them
@@ -356,23 +356,6 @@ macro_rules! impl_format_float {
 impl_format_float!(f32);
 impl_format_float!(f64);
 
-#[derive(Copy, Clone, Debug)]
-struct DefaultLogger;
-
-impl Log for DefaultLogger {
-    fn enabled(&self, metadata: &log::Metadata) -> bool {
-        log::logger().enabled(metadata)
-    }
-
-    fn log(&self, record: &Record) {
-        log::logger().log(record)
-    }
-
-    fn flush(&self) {
-        log::logger().flush()
-    }
-}
-
 #[derive(Error, Debug)]
 pub enum Error {
     #[error("log event array {} doesn't exist", MAP_NAME)]