{"id":29675752,"url":"https://github.com/oxidecomputer/slog-dtrace","last_synced_at":"2026-02-26T03:01:47.056Z","repository":{"id":42382371,"uuid":"419036417","full_name":"oxidecomputer/slog-dtrace","owner":"oxidecomputer","description":"A slog drain for emitting logging messages to DTrace","archived":false,"fork":false,"pushed_at":"2024-01-25T19:07:49.000Z","size":28,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-07-17T10:37:33.937Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxidecomputer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-19T17:58:37.000Z","updated_at":"2023-07-26T02:58:13.000Z","dependencies_parsed_at":"2023-02-08T21:15:29.977Z","dependency_job_id":null,"html_url":"https://github.com/oxidecomputer/slog-dtrace","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/oxidecomputer/slog-dtrace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fslog-dtrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fslog-dtrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fslog-dtrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fslog-dtrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxidecomputer","download_url":"https://codeload.github.com/oxidecomputer/slog-dtrace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fslog-dtrace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266591232,"owners_count":23953082,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-07-22T23:38:22.762Z","updated_at":"2026-02-26T03:01:46.998Z","avatar_url":"https://github.com/oxidecomputer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slog-dtrace\n\n[![Latest Version]][crates.io] [![Documentation]][docs.rs]\n\nForward `slog` messages as DTrace USDT probes.\n\n## Overview\n\nLogging is invaluable in production applications. However, it presents a bit of a quandary.\nMost of the time, only informational or error messages are useful. But when an application\ncrashes or is misbehaving, it can be extremely useful to retrieve more verbose logging\ninformation. Unfortunately, this can normally only be accomplished by restarting the process\nwith a new log level.\n\nThis crate allows applications to attach a `slog::Drain`, the `Dtrace` drain, to their\nloggers that forwards all messages to DTrace. This is done with a\n[`usdt`](https://docs.rs/usdt/latest) probe function, with different probes indicating\ndifferent log levels.\n\nNote that the `Dtrace` drain will _only_ send messages to DTrace, but in most situations, one\nis already sending log messages to some location (stdout, file, syslog, etc.). The\n`with_drain` constructor can be used to generate a `Dtrace` drain that will forward\nmessages to an existing drain as well as to DTrace.\n\nThe DTrace probe that emits log messages is efficient. In particular, when the probe is\ndisabled, it incurs no cost beyond that of any other drain(s) in the hierarchy. However, when\nthe probe is enabled, every message, regardless of log-level, can be viewed in DTrace.\n\n## Example\n\n```bash\n$ cargo +nightly run --example simple\n\n```\n\nYou can see that only warning messages are printed in the terminal. However, running a DTrace\ncommand in another shell should reveal more messages.\n\n```bash\n# dtrace -Z -n 'slog*::: { printf(\"%s\\n\", copyinstr(arg0)); }' -q\n{\"ok\": {\"location\":{\"module\":\"simple\",\"file\":\"examples/simple.rs\",\"line\":15},\"level\":\"WARN\",\"timestamp\":\"2021-10-19T17:55:55.260393409Z\",\"message\":\"a warning message for everyone\",\"kv\":{\"cool\":true,\"key\":\"value\"}}}\n{\"ok\": {\"location\":{\"module\":\"simple\",\"file\":\"examples/simple.rs\",\"line\":16},\"level\":\"INFO\",\"timestamp\":\"2021-10-19T17:55:55.260531762Z\",\"message\":\"info is just for dtrace\",\"kv\":{\"cool\":true,\"hello\":\"from dtrace\",\"key\":\"value\"}}}\n{\"ok\": {\"location\":{\"module\":\"simple\",\"file\":\"examples/simple.rs\",\"line\":17},\"level\":\"DEBUG\",\"timestamp\":\"2021-10-19T17:55:55.260579423Z\",\"message\":\"only dtrace gets debug messages\",\"kv\":{\"cool\":true,\"hello\":\"from dtrace\",\"key\":\"value\"}}}\n```\n\nWe can see both the warning messages that the example's stdout prints, but also an info and\ndebug message. There are specific probes for each logging level, allowing users to run DTrace\nactions in response to specific levels of messages. For example, this DTrace command receives\njust messages emitted via the `debug!` logging macro.\n\n```bash\n# dtrace -Z -n 'slog*:::debug { printf(\"%s\\n\", copyinstr(arg0)); }' -q\n{\"ok\": {\"location\":{\"module\":\"simple\",\"file\":\"examples/simple.rs\",\"line\":17},\"level\":\"DEBUG\",\"timestamp\":\"2021-10-19T17:57:30.578681933Z\",\"message\":\"only dtrace gets debug messages\",\"kv\":{\"cool\":true,\"hello\":\"from dtrace\",\"key\":\"value\"}}}\n```\n\n## Notes\n\nThis crate inherits a reliance on a nightly toolchain from the `usdt` crate.\n\n[Latest Version]: https://img.shields.io/crates/v/slog-dtrace.svg\n[crates.io]: https://crates.io/crates/slog-dtrace\n[Documentation]: https://docs.rs/slog-dtrace/badge.svg\n[docs.rs]: https://docs.rs/slog-dtrace\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Fslog-dtrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxidecomputer%2Fslog-dtrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Fslog-dtrace/lists"}