Browse Source

Use aya_log_ebpf::ufmt instead of ::ufmt

Alessandro Decina 3 years ago
parent
commit
741957f

+ 1 - 2
aya-log/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<u32, ()> {
 
 [aya]: https://github.com/aya-rs/aya
 [log]: https://docs.rs/log
-[simplelog]: https://docs.rs/simplelog
+[simplelog]: https://docs.rs/simplelog

+ 2 - 0
aya-log/aya-log-ebpf/src/lib.rs

@@ -1,5 +1,7 @@
 #![no_std]
 
+pub extern crate ufmt;
+
 mod macros;
 
 use core::{cmp, mem, ptr};

+ 2 - 1
aya-log/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())
     }}
 }

+ 1 - 0
aya-log/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(())
 }