Remove pointless DefaultLogger

This avoids an atomic load on every log.
pull/736/head
Tamir Duberstein 1 year ago
parent 412a0875b4
commit 00d265c51b
No known key found for this signature in database

@ -98,7 +98,7 @@ impl BpfLogger {
/// Starts reading log records created with `aya-log-ebpf` and logs them /// Starts reading log records created with `aya-log-ebpf` and logs them
/// with the default logger. See [log::logger]. /// with the default logger. See [log::logger].
pub fn init(bpf: &mut Bpf) -> Result<BpfLogger, Error> { 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 /// 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!(f32);
impl_format_float!(f64); 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)] #[derive(Error, Debug)]
pub enum Error { pub enum Error {
#[error("log event array {} doesn't exist", MAP_NAME)] #[error("log event array {} doesn't exist", MAP_NAME)]

Loading…
Cancel
Save