{"id":13811882,"url":"https://github.com/daangn/accesslog","last_synced_at":"2025-04-22T13:34:09.783Z","repository":{"id":38420211,"uuid":"434441901","full_name":"daangn/accesslog","owner":"daangn","description":"access logger for golang","archived":false,"fork":false,"pushed_at":"2022-06-04T09:09:32.000Z","size":317,"stargazers_count":20,"open_issues_count":6,"forks_count":0,"subscribers_count":21,"default_branch":"main","last_synced_at":"2024-08-04T04:01:33.652Z","etag":null,"topics":["access-logs","fluent-bit","golang","grpc","http","logger","logging","requestlogger"],"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/daangn.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}},"created_at":"2021-12-03T02:30:56.000Z","updated_at":"2024-02-18T12:26:28.000Z","dependencies_parsed_at":"2022-08-18T07:21:11.207Z","dependency_job_id":null,"html_url":"https://github.com/daangn/accesslog","commit_stats":null,"previous_names":["daangn/reqlog"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Faccesslog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Faccesslog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Faccesslog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daangn%2Faccesslog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daangn","download_url":"https://codeload.github.com/daangn/accesslog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223899084,"owners_count":17221874,"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":["access-logs","fluent-bit","golang","grpc","http","logger","logging","requestlogger"],"created_at":"2024-08-04T04:00:37.660Z","updated_at":"2024-11-10T00:24:02.083Z","avatar_url":"https://github.com/daangn.png","language":"Go","readme":"# accesslog\n\n[![GoDoc](https://godoc.org/github.com/daangn/accesslog?status.svg)](https://godoc.org/github.com/daangn/accesslog)\n\naccesslog provides detailed informed access logs of requests sent to your services. Each log contains information such as the timestamp of the request created, the client's IP address, latencies, request paths, and server responses. You can use these access logs to analyze traffic patterns and troubleshoot issues.  \n\n## Installation\n```shell\ngo get -u github.com/daangn/accesslog \n```\n\n## Getting started\nHere's a basic usage of logging:\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"net/http\"\n\n\t\"github.com/daangn/accesslog\"\n\t\"github.com/daangn/accesslog/middleware\"\n\t\"github.com/go-chi/chi/v5\"\n\t\"github.com/rs/zerolog\"\n)\n\nfunc main() {\n\tr := chi.NewRouter()\n\tr.Use(middleware.AccessLog(accesslog.DefaultHTTPLogger))\n\tr.Get(\"/ping\", func(w http.ResponseWriter, r *http.Request) {\n\t\taccesslog.GetLogEntry(r.Context()).Add(func(e *zerolog.Event) {\n\t\t\te.Bytes(\"data\", json.RawMessage(`{\"foo\": \"bar\"}`))\n\t\t})\n\t\tw.Write([]byte(\"pong\"))\n\t})\n\n\thttp.ListenAndServe(\":3000\", r)\n}\n\n```\n\ngo run above code in your terminal, and then execute `curl localhost:3000/ping` in another terminal.\nAfterward, you can see some logs in your terminal like below.\n```\n{\"protocol\":\"http\",\"path\":\"/ping\",\"status\":\"200\",\"ua\":\"curl/7.64.1\",\"time\":\"2021-12-09T02:39:46.026696Z\",\"elapsed(ms)\":0.033,\"data\":\"{\\\"foo\\\": \\\"bar\\\"}\"}\n```\n\nCheck out the [examples](examples) for more!\n\n## Log writers\nIn this library, the follwing log writers are available.\n\n- stdout\n- fluentd/fluent-bit\n\nIf you want one for yours, it's simple. Just implement the io.Writer.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaangn%2Faccesslog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaangn%2Faccesslog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaangn%2Faccesslog/lists"}