{"id":25121877,"url":"https://github.com/aidenwallis/slogctx","last_synced_at":"2025-07-22T04:04:41.332Z","repository":{"id":187367073,"uuid":"676777973","full_name":"aidenwallis/slogctx","owner":"aidenwallis","description":"Allows for passing extra fields to `slog` calls using context.","archived":false,"fork":false,"pushed_at":"2023-08-10T02:45:06.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T15:43:43.321Z","etag":null,"topics":["context","golang","logging","slog"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aidenwallis.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,"governance":null}},"created_at":"2023-08-10T02:00:01.000Z","updated_at":"2023-08-18T06:13:12.000Z","dependencies_parsed_at":"2023-08-10T04:09:51.672Z","dependency_job_id":null,"html_url":"https://github.com/aidenwallis/slogctx","commit_stats":null,"previous_names":["aidenwallis/slogctx"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aidenwallis/slogctx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenwallis%2Fslogctx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenwallis%2Fslogctx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenwallis%2Fslogctx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenwallis%2Fslogctx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aidenwallis","download_url":"https://codeload.github.com/aidenwallis/slogctx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aidenwallis%2Fslogctx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266424025,"owners_count":23926124,"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":["context","golang","logging","slog"],"created_at":"2025-02-08T06:37:47.259Z","updated_at":"2025-07-22T04:04:41.294Z","avatar_url":"https://github.com/aidenwallis.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slogctx\n\n[![codecov](https://codecov.io/gh/aidenwallis/slogctx/branch/main/graph/badge.svg?token=CF9slb1Sjp)](https://codecov.io/gh/aidenwallis/slogctx) [![Go Reference](https://pkg.go.dev/badge/github.com/aidenwallis/slogctx.svg)](https://pkg.go.dev/github.com/aidenwallis/slogctx)\n\nSimple [slog](https://pkg.go.dev/log/slog) wrapping handler that lets you pass fields down to a slog call through context.\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log/slog\"\n\t\"os\"\n\n\t\"github.com/aidenwallis/slogctx\"\n)\n\nvar logger = slog.New(slogctx.NewHandler(slog.NewTextHandler(os.Stdout, nil)))\n\nfunc main() {\n\tctx := context.Background()\n\n\tlogger.InfoContext(ctx, \"this message has no extra fields tied to it!\")\n\n\tctx = slogctx.WithArgs(ctx, \"passed_arg\", \"yes!\")\n\n\tdeeplyNestedFunc(ctx)\n}\n\nfunc deeplyNestedFunc(ctx context.Context) {\n\tlogger.InfoContext(ctx, \"this will attach the fields from above! particularly useful for passing through things like request URLs etc.\")\n}\n```\n\nNote that this now allows you to pass through fields using your context, rather than either deeply pushing a logger down the stack, and is compatible with the global `slog` functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidenwallis%2Fslogctx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidenwallis%2Fslogctx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidenwallis%2Fslogctx/lists"}