{"id":13827065,"url":"https://github.com/BisratYalew/logger","last_synced_at":"2025-07-09T02:33:26.804Z","repository":{"id":139886603,"uuid":"139755928","full_name":"BisratYalew/logger","owner":"BisratYalew","description":"HTTPLogger for Go Lang. It helps to log metadata about HTTP API logs and responses.","archived":false,"fork":false,"pushed_at":"2018-07-05T12:32:49.000Z","size":4,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-17T10:42:17.072Z","etag":null,"topics":["api","go","go-api","goapi","golang","golang-api","golangapi","gologger","gorestapi","http-logger","httplogger","mux","restapi"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BisratYalew.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}},"created_at":"2018-07-04T18:42:30.000Z","updated_at":"2019-05-30T17:04:42.000Z","dependencies_parsed_at":"2024-01-15T16:25:26.303Z","dependency_job_id":null,"html_url":"https://github.com/BisratYalew/logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BisratYalew%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BisratYalew%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BisratYalew%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BisratYalew%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BisratYalew","download_url":"https://codeload.github.com/BisratYalew/logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225481186,"owners_count":17481171,"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":["api","go","go-api","goapi","golang","golang-api","golangapi","gologger","gorestapi","http-logger","httplogger","mux","restapi"],"created_at":"2024-08-04T09:01:49.386Z","updated_at":"2024-11-20T06:30:47.928Z","avatar_url":"https://github.com/BisratYalew.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"This library will be very useful for you to log API Requests and Responses Including the duration time.\n\n# Usage\n\nSee [test/test.go](test/test.go)\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/bisratyalew/logger\"\n)\n\nfunc main() {\n\tclient := http.Client{\n\t\tTransport: httplogger.NewLoggedTransport(http.DefaultTransport, newLogger()),\n\t}\n\n\tclient.Get(\"http://github.com\")\n}\n\ntype httpLogger struct {\n\tlog *log.Logger\n}\n\nfunc newLogger() *httpLogger {\n\treturn \u0026httpLogger{\n\t\tlog: log.New(os.Stderr, \"log - \", log.LstdFlags),\n\t}\n}\n\nfunc (l *httpLogger) LogRequest(req *http.Request) {\n\tl.log.Printf(\n\t\t\"Request %s %s\",\n\t\treq.Method,\n\t\treq.URL.String(),\n\t)\n}\n\nfunc (l *httpLogger) LogResponse(req *http.Request, res *http.Response, err error, duration time.Duration) {\n\tduration /= time.Millisecond\n\tl.log.Printf(\n\t\t\"Response method=%s status=%d durationMs=%d %s\",\n\t\treq.Method,\n\t\tres.StatusCode,\n\t\tduration,\n\t\treq.URL.String(),\n\t)\n}\n\n```\n\nOutput:\n\n```\n% go run test/test.go\nlog - 2018/07/04 12:59:39 Request GET http://github.com\nlog - 2018/07/04 12:59:39 Response method=GET status=302\ndurationMs=101 http://github.com\nlog - 2018/07/04 12:59:39 Request GET\nhttp://github.com/bisratyalew\nlog - 2018/07/04 12:59:39 Response method=GET status=200\ndurationMs=138\nhttp://github.com/bisratyalew\n```\n\n# LICENSE\n\nThe MIT License (MIT)\n\nGOLANG HTTP LOGGER LIBRARY\nCopyright (c) 2018 Bisrat Yalew (http://github.com/bisratyalew).\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBisratYalew%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBisratYalew%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBisratYalew%2Flogger/lists"}