{"id":19113635,"url":"https://github.com/luthaf/log-once","last_synced_at":"2025-04-30T22:15:18.970Z","repository":{"id":57634956,"uuid":"74685293","full_name":"Luthaf/log-once","owner":"Luthaf","description":"Helper macros for logging events only once.","archived":false,"fork":false,"pushed_at":"2024-01-04T15:13:03.000Z","size":28,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T22:15:13.547Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Luthaf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-24T15:31:35.000Z","updated_at":"2024-04-19T08:24:54.000Z","dependencies_parsed_at":"2024-11-11T20:00:28.497Z","dependency_job_id":null,"html_url":"https://github.com/Luthaf/log-once","commit_stats":{"total_commits":30,"total_committers":5,"mean_commits":6.0,"dds":0.6666666666666667,"last_synced_commit":"28c2b86f58a2729464a3128f9f40d211e5a102fb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luthaf%2Flog-once","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luthaf%2Flog-once/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luthaf%2Flog-once/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luthaf%2Flog-once/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Luthaf","download_url":"https://codeload.github.com/Luthaf/log-once/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789621,"owners_count":21644087,"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":[],"created_at":"2024-11-09T04:36:49.476Z","updated_at":"2025-04-30T22:15:18.948Z","avatar_url":"https://github.com/Luthaf.png","language":"Rust","readme":"# log-once\n\n[![Tests](https://github.com/Luthaf/log-once/actions/workflows/tests.yml/badge.svg?event=push)](https://github.com/Luthaf/log-once/actions/workflows/tests.yml)\n[![Documentation](https://img.shields.io/badge/doc-docs.rs-green.svg)](https://docs.rs/log-once/)\n[![Crates.io version](https://img.shields.io/crates/v/log-once.svg)](https://crates.io/crates/log-once)\n\nCollection of helper macros for logging some events only once.\n\nThis crate provide macro in the `log_once` family (`warn_once!`,\n`trace_once!`, ...); that only send a logging event once for every message.\nIt rely and uses the logging infrastructure in the [log][log] crate; and\nis fully compatible with any logger implementation.\n\nThese macro will store the already seen messages in a `BTreeSet`, and check\nif a message is in the set before sending the log event.\n\n[log]: https://crates.io/crates/log\n\n## Usage\n\n1) Add it to your `Cargo.toml` file:\n\n```toml\n[dependencies]\nlog-once = \"0.4\"\n```\n\n2) import the macros:\n\n```rust\nuse log_once::{warn_once, log_once};\n```\n\n3) Enjoy!\n\n## Examples\n\n```rust\nuse log::info;\nuse log_once::{info_once, warn_once};\n\npub fn shave_the_yak(yaks: \u0026[Yak]) {\n    for yak in yaks {\n        info!(target: \"yak_events\", \"Commencing yak shaving for {yak:?}\");\n\n        loop {\n            match find_a_razor() {\n                Ok(razor) =\u003e {\n                    // This will only appear once in the logger output for each razor\n                    info_once!(\"Razor located: {razor}\");\n                    yak.shave(razor);\n                    break;\n                }\n                Err(err) =\u003e {\n                    // This will only appear once in the logger output for each error\n                    warn_once!(\"Unable to locate a razor: {err}, retrying\");\n                }\n            }\n        }\n    }\n}\n```\n\n## License\n\nlog-once is distributed under the terms of both the MIT license and the\nApache License (Version 2.0).\n\nSee [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluthaf%2Flog-once","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluthaf%2Flog-once","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluthaf%2Flog-once/lists"}