{"id":13752450,"url":"https://github.com/go-chi/httplog","last_synced_at":"2026-01-11T21:59:31.378Z","repository":{"id":40469079,"uuid":"252271479","full_name":"go-chi/httplog","owner":"go-chi","description":"Go HTTP request logger with structured logging capabilities built on \"log/slog\" package","archived":false,"fork":false,"pushed_at":"2025-09-27T08:36:59.000Z","size":61,"stargazers_count":276,"open_issues_count":9,"forks_count":43,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-27T10:23:11.966Z","etag":null,"topics":[],"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/go-chi.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-01T19:45:25.000Z","updated_at":"2025-09-27T08:37:03.000Z","dependencies_parsed_at":"2023-02-08T09:20:12.143Z","dependency_job_id":"11da8f96-10c6-44f3-8739-063344d1cce1","html_url":"https://github.com/go-chi/httplog","commit_stats":{"total_commits":40,"total_committers":10,"mean_commits":4.0,"dds":0.375,"last_synced_commit":"3bd9a169823b4ac800ffe5107b218283b5bc4bb2"},"previous_names":["goware/httplog"],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/go-chi/httplog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fhttplog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fhttplog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fhttplog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fhttplog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-chi","download_url":"https://codeload.github.com/go-chi/httplog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fhttplog/sbom","scorecard":{"id":431506,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-chi/httplog","commit":"a3123651b45676262a19d963bd29c29817486670"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Code-Review","score":4,"reason":"Found 13/30 approved changesets -- score normalized to 4","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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Maintained","score":5,"reason":"6 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"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":"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":"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":"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":"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 'master'"],"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":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3770 / GHSA-vrw8-fxc6-2r93"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 17 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"}}]},"last_synced_at":"2025-08-19T03:27:34.841Z","repository_id":40469079,"created_at":"2025-08-19T03:27:34.841Z","updated_at":"2025-08-19T03:27:34.841Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28324764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"last_error":"SSL_read: 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":"2024-08-03T09:01:06.027Z","updated_at":"2026-01-11T21:59:31.373Z","avatar_url":"https://github.com/go-chi.png","language":"Go","readme":"# httplog\n\n\u003e Structured HTTP request logging middleware for Go, built on the standard library `log/slog` package\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/go-chi/httplog/v3.svg)](https://pkg.go.dev/github.com/go-chi/httplog/v3)\n[![Go Report Card](https://goreportcard.com/badge/github.com/go-chi/httplog)](https://goreportcard.com/report/github.com/go-chi/httplog)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n`httplog` is a lightweight, high-performance HTTP request logging middleware for Go web applications. Built on Go 1.21+'s standard `log/slog` package, it provides structured logging with zero external dependencies.\n\n## Features\n\n- **🚀 High Performance**: Minimal overhead\n- **📋 Structured Logging**: Built on Go's standard `log/slog` package\n- **🎯 Smart Log Levels**: Auto-assigns levels by status code (5xx = error, 4xx = warn)\n- **📊 Schema Support**: Compatible with ECS, OTEL, and GCP logging formats\n- **🛡️ Panic Recovery**: Recovers panics with stack traces and HTTP 500 responses\n- **🔍 Body Logging**: Conditional request/response body capture with content-type filtering\n- **📝 Custom Attributes**: Add log attributes from handlers and middlewares\n- **🎨 Developer Friendly**: Concise mode and `curl` command generation\n- **🔗 Router Agnostic**: Works with [Chi](https://github.com/go-chi/chi), Gin, Echo, and standard `http.ServeMux`\n\n## Usage\n\n`go get github.com/go-chi/httplog/v3@latest`\n\n```go\npackage main\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"log/slog\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"github.com/go-chi/chi/v5\"\n\t\"github.com/go-chi/chi/v5/middleware\"\n\t\"github.com/go-chi/httplog/v3\"\n)\n\nfunc main() {\n\tlogFormat := httplog.SchemaECS.Concise(isLocalhost)\n\n\tlogger := slog.New(slog.NewJSONHandler(os.Stdout, \u0026slog.HandlerOptions{\n\t\tReplaceAttr: logFormat.ReplaceAttr,\n\t})).With(\n\t\tslog.String(\"app\", \"example-app\"),\n\t\tslog.String(\"version\", \"v1.0.0-a1fa420\"),\n\t\tslog.String(\"env\", \"production\"),\n\t)\n\n\tr := chi.NewRouter()\n\n\t// Request logger\n\tr.Use(httplog.RequestLogger(logger, \u0026httplog.Options{\n\t\t// Level defines the verbosity of the request logs:\n\t\t// slog.LevelDebug - log all responses (incl. OPTIONS)\n\t\t// slog.LevelInfo  - log responses (excl. OPTIONS)\n\t\t// slog.LevelWarn  - log 4xx and 5xx responses only (except for 429)\n\t\t// slog.LevelError - log 5xx responses only\n\t\tLevel: slog.LevelInfo,\n\n\t\t// Set log output to Elastic Common Schema (ECS) format.\n\t\tSchema: httplog.SchemaECS,\n\n\t\t// RecoverPanics recovers from panics occurring in the underlying HTTP handlers\n\t\t// and middlewares. It returns HTTP 500 unless response status was already set.\n\t\t//\n\t\t// NOTE: Panics are logged as errors automatically, regardless of this setting.\n\t\tRecoverPanics: true,\n\n\t\t// Optionally, filter out some request logs.\n\t\tSkip: func(req *http.Request, respStatus int) bool {\n\t\t\treturn respStatus == 404 || respStatus == 405\n\t\t},\n\n\t\t// Optionally, log selected request/response headers explicitly.\n\t\tLogRequestHeaders:  []string{\"Origin\"},\n\t\tLogResponseHeaders: []string{},\n\n\t\t// Optionally, enable logging of request/response body based on custom conditions.\n\t\t// Useful for debugging payload issues in development.\n\t\tLogRequestBody:  isDebugHeaderSet,\n\t\tLogResponseBody: isDebugHeaderSet,\n\t}))\n\n\t// Set request log attribute from within middleware.\n\tr.Use(func(next http.Handler) http.Handler {\n\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx := r.Context()\n\n\t\t\thttplog.SetAttrs(ctx, slog.String(\"user\", \"user1\"))\n\n\t\t\tnext.ServeHTTP(w, r.WithContext(ctx))\n\t\t})\n\t})\n\n\tr.Get(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"hello world \\n\"))\n\t})\n\n\thttp.ListenAndServe(\"localhost:8000\", r)\n}\n\nfunc isDebugHeaderSet(r *http.Request) bool {\n\treturn r.Header.Get(\"Debug\") == \"reveal-body-logs\"\n}\n```\n\n## Example\n\nSee [_example/main.go](./_example/main.go) and try it locally:\n```sh\n$ cd _example\n\n# JSON logger (production)\n$ go run .\n\n# Pretty logger (localhost)\n$ ENV=localhost go run .\n```\n\n## License\n[MIT license](./LICENSE)\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-chi%2Fhttplog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-chi%2Fhttplog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-chi%2Fhttplog/lists"}