{"id":13830299,"url":"https://github.com/PumpkinSeed/slog-context","last_synced_at":"2025-07-09T11:32:35.413Z","repository":{"id":188473971,"uuid":"678765972","full_name":"PumpkinSeed/slog-context","owner":"PumpkinSeed","description":"slog: Context handler","archived":false,"fork":false,"pushed_at":"2024-05-28T11:07:38.000Z","size":11,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-13T11:43:23.735Z","etag":null,"topics":["context","golang","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/PumpkinSeed.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-15T10:23:54.000Z","updated_at":"2024-09-15T06:20:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"52c24540-da49-4150-b62c-14faf5bb4275","html_url":"https://github.com/PumpkinSeed/slog-context","commit_stats":null,"previous_names":["pumpkinseed/slog-context"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PumpkinSeed%2Fslog-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PumpkinSeed%2Fslog-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PumpkinSeed%2Fslog-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PumpkinSeed%2Fslog-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PumpkinSeed","download_url":"https://codeload.github.com/PumpkinSeed/slog-context/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225539369,"owners_count":17485314,"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":["context","golang","slog"],"created_at":"2024-08-04T10:00:58.407Z","updated_at":"2024-11-20T11:30:36.408Z","avatar_url":"https://github.com/PumpkinSeed.png","language":"Go","readme":"# slog: Context handler\n\n![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.21-%23007d9c)\n\nA Context Handler for [slog](https://pkg.go.dev/log/slog) Go library.\n\n## Install\n\n```sh\ngo get github.com/PumpkinSeed/slog-context\n```\n\n## Usage\n\nGoDoc: [https://pkg.go.dev/github.com/PumpkinSeed/slog-context](https://pkg.go.dev/github.com/PumpkinSeed/slog-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/PumpkinSeed/slog-context\"\n)\n\ntype Struct struct {\n\tNumber int64\n\tString string\n}\n\nfunc main() {\n\t// Add slogcontext.Handler to slog\n\tslog.SetDefault(slog.New(slogcontext.NewHandler(slog.NewJSONHandler(os.Stdout, nil))))\n\n\t// Add values to context\n\tctx := slogcontext.WithValue(context.Background(), \"number\", 12)\n\tctx = slogcontext.WithValue(ctx, \"string\", \"data\")\n\tctx = slogcontext.WithValue(ctx, \"struct\", Struct{\n\t\tNumber: 42,\n\t\tString: \"struct_data\",\n\t})\n\n\t// Perform error log\n\tslog.ErrorContext(ctx, \"this is an error\")\n}\n```\n\n### Output\n\n```json\n{\"time\":\"2023-08-15T13:36:50.207418292+02:00\",\"level\":\"ERROR\",\"msg\":\"this is an error\",\"number\":12,\"string\":\"data\",\"struct\":{\"Number\":42,\"String\":\"struct_data\"}}\n```","funding_links":[],"categories":["Enrichment"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPumpkinSeed%2Fslog-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPumpkinSeed%2Fslog-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPumpkinSeed%2Fslog-context/lists"}