|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
use aya_log_common::DisplayHint;
|
|
|
|
|
use aya_log_parser::{parse, Fragment};
|
|
|
|
|
use proc_macro2::TokenStream;
|
|
|
|
|
use proc_macro2::{Ident, Span, TokenStream};
|
|
|
|
|
use quote::quote;
|
|
|
|
|
use syn::{
|
|
|
|
|
parse::{Parse, ParseStream},
|
|
|
|
@ -141,13 +141,16 @@ pub(crate) fn log(args: LogArgs, level: Option<TokenStream>) -> Result<TokenStre
|
|
|
|
|
|
|
|
|
|
let num_args = values.len();
|
|
|
|
|
let values_iter = values.iter();
|
|
|
|
|
|
|
|
|
|
let size = Ident::new("size", Span::mixed_site());
|
|
|
|
|
let len = Ident::new("len", Span::mixed_site());
|
|
|
|
|
let slice = Ident::new("slice", Span::mixed_site());
|
|
|
|
|
let record = Ident::new("record", Span::mixed_site());
|
|
|
|
|
Ok(quote! {
|
|
|
|
|
match unsafe { &mut ::aya_log_ebpf::AYA_LOG_BUF }.get_ptr_mut(0).and_then(|ptr| unsafe { ptr.as_mut() }) {
|
|
|
|
|
None => {},
|
|
|
|
|
Some(::aya_log_ebpf::LogBuf { buf }) => {
|
|
|
|
|
let _: Option<()> = (|| {
|
|
|
|
|
let size = ::aya_log_ebpf::write_record_header(
|
|
|
|
|
let #size = ::aya_log_ebpf::write_record_header(
|
|
|
|
|
buf,
|
|
|
|
|
#target,
|
|
|
|
|
#lvl,
|
|
|
|
@ -156,14 +159,14 @@ pub(crate) fn log(args: LogArgs, level: Option<TokenStream>) -> Result<TokenStre
|
|
|
|
|
line!(),
|
|
|
|
|
#num_args,
|
|
|
|
|
)?;
|
|
|
|
|
let mut size = size.get();
|
|
|
|
|
let mut #size = #size.get();
|
|
|
|
|
#(
|
|
|
|
|
let slice = buf.get_mut(size..)?;
|
|
|
|
|
let len = ::aya_log_ebpf::WriteToBuf::write(#values_iter, slice)?;
|
|
|
|
|
size += len.get();
|
|
|
|
|
let #slice = buf.get_mut(#size..)?;
|
|
|
|
|
let #len = ::aya_log_ebpf::WriteToBuf::write(#values_iter, #slice)?;
|
|
|
|
|
#size += #len.get();
|
|
|
|
|
)*
|
|
|
|
|
let record = buf.get(..size)?;
|
|
|
|
|
unsafe { &mut ::aya_log_ebpf::AYA_LOGS }.output(#ctx, record, 0);
|
|
|
|
|
let #record = buf.get(..#size)?;
|
|
|
|
|
unsafe { &mut ::aya_log_ebpf::AYA_LOGS }.output(#ctx, #record, 0);
|
|
|
|
|
Some(())
|
|
|
|
|
})();
|
|
|
|
|
}
|
|
|
|
|