lib.rs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #![no_std]
  2. #![warn(clippy::cast_lossless, clippy::cast_sign_loss)]
  3. #[cfg(target_arch = "bpf")]
  4. use aya_bpf::macros::map;
  5. use aya_bpf::maps::{PerCpuArray, PerfEventByteArray};
  6. pub use aya_log_common::{write_record_header, Level, WriteToBuf, LOG_BUF_CAPACITY};
  7. pub use aya_log_ebpf_macros::{debug, error, info, log, trace, warn};
  8. #[doc(hidden)]
  9. #[repr(C)]
  10. pub struct LogBuf {
  11. pub buf: [u8; LOG_BUF_CAPACITY],
  12. }
  13. #[doc(hidden)]
  14. // This cfg_attr prevents compilation failures on macOS where the generated section name doesn't
  15. // meet mach-o's requirements. We wouldn't ordinarily build this crate for macOS, but we do so
  16. // because the integration-test crate depends on this crate transitively. See comment in
  17. // test/integration-test/Cargo.toml.
  18. #[cfg_attr(target_arch = "bpf", map)]
  19. pub static mut AYA_LOG_BUF: PerCpuArray<LogBuf> = PerCpuArray::with_max_entries(1, 0);
  20. #[doc(hidden)]
  21. // This cfg_attr prevents compilation failures on macOS where the generated section name doesn't
  22. // meet mach-o's requirements. We wouldn't ordinarily build this crate for macOS, but we do so
  23. // because the integration-test crate depends on this crate transitively. See comment in
  24. // test/integration-test/Cargo.toml.
  25. #[cfg_attr(target_arch = "bpf", map)]
  26. pub static mut AYA_LOGS: PerfEventByteArray = PerfEventByteArray::new(0);
  27. #[doc(hidden)]
  28. pub mod macro_support {
  29. pub use aya_log_common::{
  30. DefaultFormatter, DisplayHint, IpFormatter, Level, LowerHexFormatter, LowerMacFormatter,
  31. UpperHexFormatter, UpperMacFormatter, LOG_BUF_CAPACITY,
  32. };
  33. pub use aya_log_ebpf_macros::log;
  34. }