From 069013ddc99429d517a7417162ff3b569641c60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alessandro=C2=A0Decina?= Date: Sat, 2 Oct 2021 11:02:04 +0000 Subject: [PATCH] Use aya_log_ebpf::ufmt instead of ::ufmt --- README.md | 3 +-- aya-log-ebpf/src/lib.rs | 2 ++ aya-log-ebpf/src/macros.rs | 3 ++- aya-log/src/lib.rs | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 186c3898..f8e5b872 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ Add `aya-log-ebpf` and `ufmt` to `Cargo.toml`: ```toml [dependencies] aya-log-ebpf = { git = "https://github.com/aya-rs/aya-log", branch = "main" } -ufmt = "0.1" ``` ## Example @@ -70,4 +69,4 @@ fn try_xdp_firewall(ctx: XdpContext) -> Result { [aya]: https://github.com/aya-rs/aya [log]: https://docs.rs/log -[simplelog]: https://docs.rs/simplelog \ No newline at end of file +[simplelog]: https://docs.rs/simplelog diff --git a/aya-log-ebpf/src/lib.rs b/aya-log-ebpf/src/lib.rs index 2b361e40..ad0ab8b5 100644 --- a/aya-log-ebpf/src/lib.rs +++ b/aya-log-ebpf/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] +pub extern crate ufmt; + mod macros; use core::{cmp, mem, ptr}; diff --git a/aya-log-ebpf/src/macros.rs b/aya-log-ebpf/src/macros.rs index e982f67e..fd56c534 100644 --- a/aya-log-ebpf/src/macros.rs +++ b/aya-log-ebpf/src/macros.rs @@ -195,7 +195,8 @@ macro_rules! log { #[macro_export] macro_rules! write_record_message { ($buf:expr, $($arg:tt)+) => {{ + use aya_log_ebpf::ufmt; let mut writer = $crate::LogBufWriter::new($buf); - ufmt::uwrite!(writer, $($arg)+).map(|_| writer.finish()) + aya_log_ebpf::ufmt::uwrite!(writer, $($arg)+).map(|_| writer.finish()) }} } diff --git a/aya-log/src/lib.rs b/aya-log/src/lib.rs index 5a75724c..838fe5a5 100644 --- a/aya-log/src/lib.rs +++ b/aya-log/src/lib.rs @@ -167,6 +167,7 @@ fn log_buf(mut buf: &[u8], logger: &dyn Log) -> Result<(), ()> { .line(line) .build(), ); + logger.flush(); Ok(()) }