{"id":13720523,"url":"https://github.com/aya-rs/aya-log","last_synced_at":"2025-05-07T12:31:38.868Z","repository":{"id":38193784,"uuid":"408251519","full_name":"aya-rs/aya-log","owner":"aya-rs","description":"A logging library for eBPF programs.","archived":true,"fork":false,"pushed_at":"2022-07-28T18:54:47.000Z","size":35,"stargazers_count":22,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-14T09:39:17.533Z","etag":null,"topics":["ebpf","logging","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aya-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-19T22:33:02.000Z","updated_at":"2024-04-18T01:09:14.000Z","dependencies_parsed_at":"2022-08-18T18:00:32.231Z","dependency_job_id":null,"html_url":"https://github.com/aya-rs/aya-log","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aya-rs%2Faya-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aya-rs%2Faya-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aya-rs%2Faya-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aya-rs%2Faya-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aya-rs","download_url":"https://codeload.github.com/aya-rs/aya-log/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252876430,"owners_count":21818178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ebpf","logging","rust"],"created_at":"2024-08-03T01:01:04.801Z","updated_at":"2025-05-07T12:31:33.857Z","avatar_url":"https://github.com/aya-rs.png","language":"Rust","funding_links":[],"categories":["Aya eBPF-Side Libraries"],"sub_categories":["Aya-related talks"],"readme":"**This repo has been moved. It is now located at https://github.com/aya-rs/aya**\n\n# aya-log - a logging library for eBPF programs\n\n## Overview\n\n`aya-log` is a logging library for eBPF programs written using [aya]. Think of\nit as the [log] crate for eBPF.\n\n## Installation\n\n### User space\n\nAdd `aya-log` to `Cargo.toml`:\n\n```toml\n[dependencies]\naya-log = { git = \"https://github.com/aya-rs/aya-log\", branch = \"main\" }\n```\n\n### eBPF side\n\nAdd `aya-log-ebpf` to `Cargo.toml`:\n\n```toml\n[dependencies]\naya-log-ebpf = { git = \"https://github.com/aya-rs/aya-log\", branch = \"main\" }\n```\n\n## Example\n\nHere's an example that uses `aya-log` in conjunction with the [simplelog] crate\nto log eBPF messages to the terminal.\n\n### User space code\n\n```rust\nuse simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};\nuse aya_log::BpfLogger;\n\nTermLogger::init(\n    LevelFilter::Debug,\n    ConfigBuilder::new()\n        .set_target_level(LevelFilter::Error)\n        .set_location_level(LevelFilter::Error)\n        .build(),\n    TerminalMode::Mixed,\n    ColorChoice::Auto,\n)\n.unwrap();\n\n// Will log using the default logger, which is TermLogger in this case\nBpfLogger::init(\u0026mut bpf).unwrap();\n```\n\n### eBPF code\n\n```rust\nuse aya_log_ebpf::info;\n\nfn try_xdp_firewall(ctx: XdpContext) -\u003e Result\u003cu32, ()\u003e {\n    if let Some(port) = tcp_dest_port(\u0026ctx)? {\n        if block_port(port) {\n            info!(\u0026ctx, \"❌ blocked incoming connection on port: {}\", port);\n            return Ok(XDP_DROP);\n        }\n    }\n\n    Ok(XDP_PASS)\n}\n```\n\n[aya]: https://github.com/aya-rs/aya\n[log]: https://docs.rs/log\n[simplelog]: https://docs.rs/simplelog\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faya-rs%2Faya-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faya-rs%2Faya-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faya-rs%2Faya-log/lists"}