Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flexoid/go-utils
Golang utils and helpers
https://github.com/flexoid/go-utils
Last synced: 28 days ago
JSON representation
Golang utils and helpers
- Host: GitHub
- URL: https://github.com/flexoid/go-utils
- Owner: flexoid
- Created: 2019-01-13T18:15:43.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-13T18:51:32.000Z (almost 6 years ago)
- Last Synced: 2024-10-12T07:47:18.994Z (3 months ago)
- Language: Go
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/flexoid/go-utils?status.svg)](https://godoc.org/github.com/flexoid/go-utils)
The collection of helper functions, utils and code snippets that can be useful
for my golang projects.# Content
## `go-utils/logging`
[logging.RequestLogger](https://godoc.org/github.com/flexoid/go-utils/logging#RequestLogger)
A middleware function that logs request start and request end with zerolog.
A logger instance is taken from the request context.```
2019-01-13T18:46:34.488192Z |INFO| Request started req_id=bgtof2ml0s1adiaerc70
2019-01-13T18:46:35.035226Z |INFO| Request completed bytes=3326 elapsed_ms=547.028988 http_method=GET remote_addr=[::1]:61052 req_id=bgtof2ml0s1adiaerc70 status_code=200 uri=http://localhost:4000/api/users/123 user_agent=HTTPie/0.9.9
``````
{"level":"info","req_id":"bgtoflul0s1afn7goou0","time":"2019-01-13T18:47:51.118414Z","message":"Request started"}
{"level":"info","req_id":"bgtoflul0s1afn7goou0","status_code":200,"http_method":"GET","uri":"http://localhost:4000/api/users/123","remote_addr":"[::1]:61079","user_agent":"HTTPie/0.9.9","bytes":3326,"elapsed_ms":477.652781,"time":"2019-01-13T18:47:51.596075Z","message":"Request completed"}
```