{"id":13830435,"url":"https://github.com/samber/slog-chi","last_synced_at":"2026-04-29T19:00:44.809Z","repository":{"id":200360377,"uuid":"705345905","full_name":"samber/slog-chi","owner":"samber","description":"🚨 Chi middleware for slog logger","archived":false,"fork":false,"pushed_at":"2026-04-01T09:46:31.000Z","size":143,"stargazers_count":90,"open_issues_count":2,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-01T11:40:19.390Z","etag":null,"topics":["attribute","chi","error","errors","go","golang","handler","http","log","log-level","logger","middleware","slog","structured-logging"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/samber/slog-chi","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/samber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["samber"]}},"created_at":"2023-10-15T18:53:29.000Z","updated_at":"2026-04-01T09:46:34.000Z","dependencies_parsed_at":"2023-10-25T21:33:22.378Z","dependency_job_id":"bb9b86c5-7f2c-49ef-8b8d-f3ab99fe64b1","html_url":"https://github.com/samber/slog-chi","commit_stats":null,"previous_names":["samber/slog-chi"],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/samber/slog-chi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-chi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-chi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-chi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-chi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samber","download_url":"https://codeload.github.com/samber/slog-chi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fslog-chi/sbom","scorecard":{"id":381768,"data":{"date":"2025-08-11","repo":{"name":"github.com/samber/slog-chi","commit":"ed45d19f09cc664193d532bd00314ac072f198c3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Maintained","score":4,"reason":"5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/18 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/samber/slog-chi/test.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/lint.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T15:37:09.160Z","repository_id":200360377,"created_at":"2025-08-18T15:37:09.160Z","updated_at":"2025-08-18T15:37:09.160Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32439301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T18:12:22.909Z","status":"ssl_error","status_checked_at":"2026-04-29T18:11:33.322Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["attribute","chi","error","errors","go","golang","handler","http","log","log-level","logger","middleware","slog","structured-logging"],"created_at":"2024-08-04T10:00:59.863Z","updated_at":"2026-04-29T19:00:44.801Z","avatar_url":"https://github.com/samber.png","language":"Go","funding_links":["https://github.com/sponsors/samber"],"categories":["Integrations"],"sub_categories":[],"readme":"\n# slog: Chi middleware\n\n[![tag](https://img.shields.io/github/tag/samber/slog-chi.svg)](https://github.com/samber/slog-chi/releases)\n![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.21-%23007d9c)\n[![GoDoc](https://godoc.org/github.com/samber/slog-chi?status.svg)](https://pkg.go.dev/github.com/samber/slog-chi)\n![Build Status](https://github.com/samber/slog-chi/actions/workflows/test.yml/badge.svg)\n[![Go report](https://goreportcard.com/badge/github.com/samber/slog-chi)](https://goreportcard.com/report/github.com/samber/slog-chi)\n[![Coverage](https://img.shields.io/codecov/c/github/samber/slog-chi)](https://codecov.io/gh/samber/slog-chi)\n[![Contributors](https://img.shields.io/github/contributors/samber/slog-chi)](https://github.com/samber/slog-chi/graphs/contributors)\n[![License](https://img.shields.io/github/license/samber/slog-chi)](./LICENSE)\n\n[Chi](https://github.com/go-chi/chi) middleware to log http requests using [slog](https://pkg.go.dev/log/slog).\n\n\u003cdiv align=\"center\"\u003e\n  \u003chr\u003e\n  \u003csup\u003e\u003cb\u003eSponsored by:\u003c/b\u003e\u003c/sup\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://cast.ai/samuel\"\u003e\n    \u003cdiv\u003e\n      \u003cimg src=\"https://github.com/user-attachments/assets/502f8fa8-e7e8-4754-a51f-036d0443e694\" width=\"200\" alt=\"Cast AI\"\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n      Cut Kubernetes \u0026 AI costs, boost application stability\n    \u003c/div\u003e\n  \u003c/a\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://www.dash0.com?utm_campaign=148395251-samber%20github%20sponsorship\u0026utm_source=github\u0026utm_medium=sponsorship\u0026utm_content=samber\"\u003e\n    \u003cdiv\u003e\n      \u003cimg src=\"https://github.com/user-attachments/assets/b1f2e876-0954-4dc3-824d-935d29ba8f3f\" width=\"200\" alt=\"Dash0\"\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n      100% OpenTelemetry-native observability platform\u003cbr\u003eSimple to use, built on open standards, and designed for full cost control\n    \u003c/div\u003e\n  \u003c/a\u003e\n  \u003chr\u003e\n\u003c/div\u003e\n\n**See also:**\n\n- [slog-multi](https://github.com/samber/slog-multi): `slog.Handler` chaining, fanout, routing, failover, load balancing...\n- [slog-formatter](https://github.com/samber/slog-formatter): `slog` attribute formatting\n- [slog-sampling](https://github.com/samber/slog-sampling): `slog` sampling policy\n- [slog-mock](https://github.com/samber/slog-mock): `slog.Handler` for test purposes\n\n**HTTP middlewares:**\n\n- [slog-gin](https://github.com/samber/slog-gin): Gin middleware for `slog` logger\n- [slog-echo](https://github.com/samber/slog-echo): Echo middleware for `slog` logger\n- [slog-fiber](https://github.com/samber/slog-fiber): Fiber middleware for `slog` logger\n- [slog-chi](https://github.com/samber/slog-chi): Chi middleware for `slog` logger\n- [slog-http](https://github.com/samber/slog-http): `net/http` middleware for `slog` logger\n\n**Loggers:**\n\n- [slog-zap](https://github.com/samber/slog-zap): A `slog` handler for `Zap`\n- [slog-zerolog](https://github.com/samber/slog-zerolog): A `slog` handler for `Zerolog`\n- [slog-logrus](https://github.com/samber/slog-logrus): A `slog` handler for `Logrus`\n\n**Log sinks:**\n\n- [slog-datadog](https://github.com/samber/slog-datadog): A `slog` handler for `Datadog`\n- [slog-betterstack](https://github.com/samber/slog-betterstack): A `slog` handler for `Betterstack`\n- [slog-rollbar](https://github.com/samber/slog-rollbar): A `slog` handler for `Rollbar`\n- [slog-loki](https://github.com/samber/slog-loki): A `slog` handler for `Loki`\n- [slog-sentry](https://github.com/samber/slog-sentry): A `slog` handler for `Sentry`\n- [slog-syslog](https://github.com/samber/slog-syslog): A `slog` handler for `Syslog`\n- [slog-logstash](https://github.com/samber/slog-logstash): A `slog` handler for `Logstash`\n- [slog-fluentd](https://github.com/samber/slog-fluentd): A `slog` handler for `Fluentd`\n- [slog-graylog](https://github.com/samber/slog-graylog): A `slog` handler for `Graylog`\n- [slog-quickwit](https://github.com/samber/slog-quickwit): A `slog` handler for `Quickwit`\n- [slog-slack](https://github.com/samber/slog-slack): A `slog` handler for `Slack`\n- [slog-telegram](https://github.com/samber/slog-telegram): A `slog` handler for `Telegram`\n- [slog-mattermost](https://github.com/samber/slog-mattermost): A `slog` handler for `Mattermost`\n- [slog-microsoft-teams](https://github.com/samber/slog-microsoft-teams): A `slog` handler for `Microsoft Teams`\n- [slog-webhook](https://github.com/samber/slog-webhook): A `slog` handler for `Webhook`\n- [slog-kafka](https://github.com/samber/slog-kafka): A `slog` handler for `Kafka`\n- [slog-nats](https://github.com/samber/slog-nats): A `slog` handler for `NATS`\n- [slog-parquet](https://github.com/samber/slog-parquet): A `slog` handler for `Parquet` + `Object Storage`\n- [slog-channel](https://github.com/samber/slog-channel): A `slog` handler for Go channels\n\n## 🚀 Install\n\n```sh\ngo get github.com/samber/slog-chi\n```\n\n**Compatibility**: go \u003e= 1.21\n\nNo breaking changes will be made to exported APIs before v2.0.0.\n\n## 💡 Usage\n\n### Handler options\n\n```go\ntype Config struct {\n\tDefaultLevel     slog.Level\n\tClientErrorLevel slog.Level\n\tServerErrorLevel slog.Level\n\n\tWithUserAgent      bool\n\tWithRequestID      bool\n\tWithRequestBody    bool\n\tWithRequestHeader  bool\n\tWithResponseBody   bool\n\tWithResponseHeader bool\n\tWithSpanID         bool\n\tWithTraceID        bool\n\tWithClientIP       bool\n\tWithCustomMessage  func(w http.ResponseWriter, r *http.Request) string\n\n\tFilters []Filter\n}\n```\n\nAttributes will be injected in log payload.\n\nOther global parameters:\n\n```go\nslogchi.TraceIDKey = \"trace_id\"\nslogchi.SpanIDKey = \"span_id\"\nslogchi.RequestIDKey = \"id\"\nslogchi.RequestBodyMaxSize  = 64 * 1024 // 64KB\nslogchi.ResponseBodyMaxSize = 64 * 1024 // 64KB\nslogchi.HiddenRequestHeaders = map[string]struct{}{ ... }\nslogchi.HiddenResponseHeaders = map[string]struct{}{ ... }\n```\n\n### Minimal\n\n```go\nimport (\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/go-chi/chi/v5\"\n\t\"github.com/go-chi/chi/v5/middleware\"\n\tslogchi \"github.com/samber/slog-chi\"\n\t\"log/slog\"\n)\n\n// Create a slog logger, which:\n//   - Logs to stdout.\nlogger := slog.New(slog.NewTextHandler(os.Stdout, nil))\n\n// Chi instance\nrouter := chi.NewRouter()\n\n// Middleware\nrouter.Use(slogchi.New(logger))\nrouter.Use(middleware.Recoverer)\n\n// Routes\nrouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Hello, World!\"))\n})\nrouter.GET(\"/error\", func(w http.ResponseWriter, r *http.Request) {\n\thttp.Error(w, http.StatusText(400), 400)\n})\n\n// Start server\nerr := http.ListenAndServe(\":4242\", router)\n\n// output:\n// time=2023-10-15T20:32:58.926+02:00 level=INFO msg=\"200: OK\" env=production request.time=2023-10-15T20:32:58.626+02:00 request.method=GET request.path=/ request.route=\"\" request.ip=127.0.0.1:63932 request.length=0 response.time=2023-10-15T20:32:58.926+02:00 response.latency=100ms response.status=200 response.length=7 id=\"\"\n```\n\n### OTEL\n\n```go\nlogger := slog.New(slog.NewTextHandler(os.Stdout, nil))\n\nconfig := slogchi.Config{\n\tWithSpanID:  true,\n\tWithTraceID: true,\n}\n\nrouter := chi.NewRouter()\nrouter.Use(slogchi.NewWithConfig(logger, config))\nrouter.Use(middleware.Recoverer)\n```\n\n### Custom log levels\n\n```go\nlogger := slog.New(slog.NewTextHandler(os.Stdout, nil))\n\nconfig := slogchi.Config{\n\tDefaultLevel:     slog.LevelInfo,\n\tClientErrorLevel: slog.LevelWarn,\n\tServerErrorLevel: slog.LevelError,\n}\n\nrouter := chi.NewRouter()\nrouter.Use(slogchi.NewWithConfig(logger, config))\nrouter.Use(middleware.Recoverer)\n```\n\n### Verbose\n\n```go\nlogger := slog.New(slog.NewTextHandler(os.Stdout, nil))\n\nconfig := slogchi.Config{\n\tWithRequestBody: true,\n\tWithResponseBody: true,\n\tWithRequestHeader: true,\n\tWithResponseHeader: true,\n}\n\nrouter := chi.NewRouter()\nrouter.Use(slogchi.NewWithConfig(logger, config))\nrouter.Use(middleware.Recoverer)\n```\n\n### Filters\n\n```go\nlogger := slog.New(slog.NewTextHandler(os.Stdout, nil))\n\nrouter := chi.NewRouter()\nrouter.Use(\n\tslogchi.NewWithFilters(\n\t\tlogger,\n\t\tslogchi.Accept(func (ww middleware.WrapResponseWriter, r *http.Request) bool {\n\t\t\treturn xxx\n\t\t}),\n\t\tslogchi.IgnoreStatus(401, 404),\n\t),\n)\nrouter.Use(middleware.Recoverer)\n```\n\nAvailable filters:\n- Accept / Ignore\n- AcceptMethod / IgnoreMethod\n- AcceptStatus / IgnoreStatus\n- AcceptStatusGreaterThan / IgnoreStatusGreaterThan\n- AcceptStatusLessThan / IgnoreStatusLessThan\n- AcceptStatusGreaterThanOrEqual / IgnoreStatusGreaterThanOrEqual\n- AcceptStatusLessThanOrEqual / IgnoreStatusLessThanOrEqual\n- AcceptPath / IgnorePath\n- AcceptPathContains / IgnorePathContains\n- AcceptPathPrefix / IgnorePathPrefix\n- AcceptPathSuffix / IgnorePathSuffix\n- AcceptPathMatch / IgnorePathMatch\n- AcceptHost / IgnoreHost\n- AcceptHostContains / IgnoreHostContains\n- AcceptHostPrefix / IgnoreHostPrefix\n- AcceptHostSuffix / IgnoreHostSuffix\n- AcceptHostMatch / IgnoreHostMatch\n\n### Using custom time formatters\n\n```go\nimport (\n\t\"github.com/go-chi/chi/v5\"\n\t\"github.com/go-chi/chi/v5/middleware\"\n\tslogchi \"github.com/samber/slog-chi\"\n\tslogformatter \"github.com/samber/slog-formatter\"\n\t\"log/slog\"\n)\n\n// Create a slog logger, which:\n//   - Logs to stdout.\n//   - RFC3339 with UTC time format.\nlogger := slog.New(\n\tslogformatter.NewFormatterHandler(\n\t\tslogformatter.TimezoneConverter(time.UTC),\n\t\tslogformatter.TimeFormatter(time.DateTime, nil),\n\t)(\n\t\tslog.NewTextHandler(os.Stdout, nil),\n\t),\n)\n\n// Chi instance\nrouter := chi.NewRouter()\n\n// Middleware\nrouter.Use(slogchi.New(logger))\nrouter.Use(middleware.Recoverer)\n\n// Routes\nrouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Hello, World!\"))\n})\nrouter.GET(\"/error\", func(w http.ResponseWriter, r *http.Request) {\n\thttp.Error(w, http.StatusText(400), 400)\n})\n\n// Start server\nerr := http.ListenAndServe(\":4242\", router)\n\n// output:\n// time=2023-10-15T20:32:58.926+02:00 level=INFO msg=\"200: OK\" env=production request.time=2023-10-15T20:32:58.626Z request.method=GET request.path=/ request.route=\"\" request.ip=127.0.0.1:63932 request.length=0 response.time=2023-10-15T20:32:58Z response.latency=100ms response.status=200 response.length=7 id=\"\"\n```\n\n### Using custom logger sub-group\n\n```go\nlogger := slog.New(slog.NewTextHandler(os.Stdout, nil))\n\n// Chi instance\nrouter := chi.NewRouter()\n\n// Middleware\nrouter.Use(slogchi.New(logger.WithGroup(\"http\")))\nrouter.Use(middleware.Recoverer)\n\n// Routes\nrouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Hello, World!\"))\n})\nrouter.GET(\"/error\", func(w http.ResponseWriter, r *http.Request) {\n\thttp.Error(w, http.StatusText(400), 400)\n})\n\n// Start server\nerr := http.ListenAndServe(\":4242\", router)\n\n// output:\n// time=2023-10-15T20:32:58.926+02:00 level=INFO msg=\"200: OK\" env=production http.request.time=2023-10-15T20:32:58.626+02:00 http.request.method=GET http.request.path=/ http.request.route=\"\" http.request.ip=127.0.0.1:63932 http.request.length=0 http.response.time=2023-10-15T20:32:58.926+02:00 http.response.latency=100ms http.response.status=200 http.response.length=7 http.id=\"\"\n```\n\n### Adding custom attributes\n\n```go\nlogger := slog.New(slog.NewTextHandler(os.Stdout, nil))\n\n// Add an attribute to all log entries made through this logger.\nlogger = logger.With(\"env\", \"production\")\n\n// Chi instance\nrouter := chi.NewRouter()\n\n// Middleware\nrouter.Use(slogchi.New(logger))\nrouter.Use(middleware.Recoverer)\n\n// Routes\nrouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t// Add an attribute to a single log entry.\n\tslogchi.AddCustomAttributes(r, slog.String(\"foo\", \"bar\"))\n\tw.Write([]byte(\"Hello, World!\"))\n})\n\n// Start server\nerr := http.ListenAndServe(\":4242\", router)\n\n// output:\n// time=2023-10-15T20:32:58.926+02:00 level=INFO msg=\"200: OK\" env=production request.time=2023-10-15T20:32:58.626+02:00 request.method=GET request.path=/ request.route=\"\" request.ip=127.0.0.1:63932 request.length=0 response.time=2023-10-15T20:32:58.926+02:00 response.latency=100ms response.status=200 response.length=7 id=\"\" foo=bar\n```\n\n### JSON output\n\n```go\nlogger := slog.New(slog.NewJSONHandler(os.Stdout, nil))\n\n// Chi instance\nrouter := chi.NewRouter()\n\n// Middleware\nrouter.Use(slogchi.New(logger))\nrouter.Use(middleware.Recoverer)\n\n// Routes\nrouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Hello, World!\"))\n})\n\n// Start server\nerr := http.ListenAndServe(\":4242\", router)\n\n// output:\n// {\"time\":\"2023-10-15T20:32:58.926+02:00\",\"level\":\"INFO\",\"msg\":\"200: OK\",\"env\":\"production\",\"http\":{\"request\":{\"time\":\"2023-10-15T20:32:58.626+02:00\",\"method\":\"GET\",\"path\":\"/\",\"route\":\"\",\"ip\":\"127.0.0.1:55296\",\"length\":0},\"response\":{\"time\":\"2023-10-15T20:32:58.926+02:00\",\"latency\":100000,\"status\":200,\"length\":7},\"id\":\"\"}}\n```\n\n## 🤝 Contributing\n\n- Ping me on twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :))\n- Fork the [project](https://github.com/samber/slog-chi)\n- Fix [open issues](https://github.com/samber/slog-chi/issues) or request new features\n\nDon't hesitate ;)\n\n```bash\n# Install some dev dependencies\nmake tools\n\n# Run tests\nmake test\n# or\nmake watch-test\n```\n\n## 👤 Contributors\n\n![Contributors](https://contrib.rocks/image?repo=samber/slog-chi)\n\n## 💫 Show your support\n\nGive a ⭐️ if this project helped you!\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/samber?style=for-the-badge)](https://github.com/sponsors/samber)\n\n## 📝 License\n\nCopyright © 2023 [Samuel Berthe](https://github.com/samber).\n\nThis project is [MIT](./LICENSE) licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamber%2Fslog-chi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamber%2Fslog-chi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamber%2Fslog-chi/lists"}