{"id":36790917,"url":"https://github.com/csmith/slogflags","last_synced_at":"2026-01-12T13:25:34.096Z","repository":{"id":292002377,"uuid":"979498529","full_name":"csmith/slogflags","owner":"csmith","description":"Flags for log/slog","archived":false,"fork":false,"pushed_at":"2025-05-17T16:16:12.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-17T17:26:29.966Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/csmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-05-07T15:51:05.000Z","updated_at":"2025-05-17T16:16:10.000Z","dependencies_parsed_at":"2025-05-07T16:51:25.902Z","dependency_job_id":"2e2a8bd3-c008-4414-817a-391f86546875","html_url":"https://github.com/csmith/slogflags","commit_stats":null,"previous_names":["csmith/slogflags"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/csmith/slogflags","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fslogflags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fslogflags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fslogflags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fslogflags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csmith","download_url":"https://codeload.github.com/csmith/slogflags/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csmith%2Fslogflags/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28339002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-12T13:25:33.913Z","updated_at":"2026-01-12T13:25:34.058Z","avatar_url":"https://github.com/csmith.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slogflags\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/csmith/slogflags)](https://pkg.go.dev/github.com/csmith/slogflags)\n\nProvides flags to configure the go structured logging package.\n\n## Why?\n\nHow logs are formatted and what levels should be output depend on where and how\nan application is deployed. For general purpose applications, they can't really\nbe set at compile time: some users will want JSON logs, others may want to\nenable debug log levels to diagnose an issue, and so on.\n\nThe slog package doesn't provide a nice way of handling this, so `slogflags` was\ncreated.\n\n## How?\n\nIn the most basic case, import this package, call `flag.Parse()`, and then\nretrieve your brand new logger by calling `slogflags.Logger()`:\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"github.com/csmith/slogflags\"\n)\n\nfunc main() {\n\tflag.Parse()\n\tl := slogflags.Logger()\n\tl.Warn(\"Danger\", \"user\", \"Will Robinson\")\n}\n```\n\nYou can then run the app and specify `--log.level` (one of \"debug\", \"info\",\n\"warn\" and \"error\") and `--log.format` (either \"text\" or \"json\").\n\n## More advanced usage\n\nYou can pass options in to the `Logger` call to change the default behaviour.\nSee the godocs for a full list. The most useful one is perhaps `SetDefault`,\nwhich sets the new logger as the default for the slog package. This also\nenables bridging of calls from the `log` package.\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"github.com/csmith/slogflags\"\n\t\"log\"\n)\n\nfunc main() {\n\tflag.Parse()\n\tl := slogflags.Logger(slogflags.WithSetDefault(true))\n\tl.Warn(\"Danger\", \"user\", \"Will Robinson\")\n\tlog.Printf(\"I'll show up properly now too!\")\n}\n```\n\n## Licence/credits/contributions etc\n\nReleased under the MIT licence. See LICENCE for full details.\n\nContributions are welcome! Please feel free to open issues or send pull requests.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsmith%2Fslogflags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsmith%2Fslogflags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsmith%2Fslogflags/lists"}