Expand description
A logging framework for eBPF programs.
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 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.
§Example:
This example uses the env_logger crate to log messages to the terminal.
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
EbpfLogger::init(&mut bpf).unwrap();
With the following eBPF code:
â
use aya_log_ebpf::{debug, error, info, trace, warn};
error!(&ctx, "this is an error message đ¨");
warn!(&ctx, "this is a warning message â ī¸");
info!(&ctx, "this is an info message âšī¸");
debug!(&ctx, "this is a debug message ī¸đ");
trace!(&ctx, "this is a trace message đ");
Outputs:
21:58:55 [ERROR] xxx: [src/main.rs:35] this is an error message đ¨
21:58:55 [WARN] xxx: [src/main.rs:36] this is a warning message â ī¸
21:58:55 [INFO] xxx: [src/main.rs:37] this is an info message âšī¸
21:58:55 [DEBUG] (7) xxx: [src/main.rs:38] this is a debug message ī¸đ
21:58:55 [TRACE] (7) xxx: [src/main.rs:39] this is a trace message đ
Structs§
- Log messages generated by
aya_log_ebpf
using the log crate.