{"id":18368515,"url":"https://github.com/slog-rs/derive","last_synced_at":"2025-04-06T17:31:42.887Z","repository":{"id":57667672,"uuid":"120849301","full_name":"slog-rs/derive","owner":"slog-rs","description":null,"archived":false,"fork":false,"pushed_at":"2019-10-12T08:16:47.000Z","size":21,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T04:02:00.280Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slog-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-09T03:05:00.000Z","updated_at":"2023-07-25T14:14:53.000Z","dependencies_parsed_at":"2022-09-03T10:22:54.885Z","dependency_job_id":null,"html_url":"https://github.com/slog-rs/derive","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slog-rs%2Fderive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slog-rs%2Fderive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slog-rs%2Fderive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slog-rs%2Fderive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slog-rs","download_url":"https://codeload.github.com/slog-rs/derive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247522358,"owners_count":20952531,"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-05T23:26:10.941Z","updated_at":"2025-04-06T17:31:42.554Z","avatar_url":"https://github.com/slog-rs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slog Derives\n\n[![Build Status](https://travis-ci.org/slog-rs/derive.svg?branch=master)](https://travis-ci.org/slog-rs/derive)\n[![Crates.io Link](https://img.shields.io/crates/v/slog_derive.svg)](https://crates.io/crates/slog_derive)\n[![Online Documentation](https://docs.rs/slog_derive/badge.svg)](https://docs.rs/slog_derive)\n\nCustom derives for use with [slog] logging.\n\n\n## The `KV` Derive\n\nSometimes you'll want to log the struct's contents in your application, for\nexample when you've just started and want to record the configuration\ndetails for debugging purposes. Usually you'd need to do something like\nthis:\n\n```rust\n#[macro_use]\nextern crate slog;\nuse std::path::PathBuf;\n\nstruct Config {\n    width: f64,\n    height: f64,\n    url: String,\n}\n\nlet cfg = Config { ... };\n\ndebug!(logger, \"Loaded Config\";\n    \"width\" =\u003e cfg.width,\n    \"height\" =\u003e cfg.height,\n    \"url\" =\u003e cfg.url);\n# }\n```\n\nThis is where the [`KV`] trait comes in. Implementing it lets you log a type\nas a bunch of key-value pairs, translating the previous log statement into \nsomething like this:\n\n```rust\ndebug!(logger, \"Loaded Config\"; cfg);\n```\n\nThis crate provides a custom derive which will implement [`KV`] for you.\nIt'll just iterate over each field in your `struct` and invoke\n[`Value::serialize()`] on each. You can also use the `#[slog(skip)]` attribute\nto skip specific fields.\n\n```rust\n#[derive(KV)]\npub struct Config {\n  width: f64,\n  height: f64,\n  #[slog(skip)]\n  url: String,\n}\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE.md) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT.md) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms or\nconditions.\n\n\n[`KV`]: https://docs.rs/slog/2.1.1/slog/trait.KV.html\n[`Value::serialize()`]: https://docs.rs/slog/2.1.1/slog/trait.Value.html#tymethod.serialize\n[slog]: https://github.com/slog-rs/slog","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslog-rs%2Fderive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslog-rs%2Fderive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslog-rs%2Fderive/lists"}