Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thedanielforum/apex-gin
Gin middleware for Apex-log
https://github.com/thedanielforum/apex-gin
apex-logger apex-logs gin gin-middleware go golang structured-logging
Last synced: 27 days ago
JSON representation
Gin middleware for Apex-log
- Host: GitHub
- URL: https://github.com/thedanielforum/apex-gin
- Owner: thedanielforum
- Created: 2017-05-29T03:23:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-28T11:17:40.000Z (almost 7 years ago)
- Last Synced: 2024-10-30T03:45:30.402Z (3 months ago)
- Topics: apex-logger, apex-logs, gin, gin-middleware, go, golang, structured-logging
- Language: Go
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Gin middleware for Apex-log
Middleware for [gin-gonic](https://github.com/gin-gonic/gin) and [apex-log](https://github.com/apex/log)
[](https://godoc.org/github.com/thedanielforum/apex-gin)
Example output
```text
INFO[0005] client_ip=127.0.0.1 latency=168.439199ms method=PUT path=/v1/user/info/123 status_code=200 message=test message
```*Install*
```bash
go get https://github.com/thedanielforum/apex-gin-middleware
```*How to use*
```go
// Configure apex-log handler
log.SetHandler(text.New(os.Stderr))// Configure gin
r := gin.New()// Tell gin to use apex_gin middleware
r.Use(apex_gin.Handler("test message"))// Define routes
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})// Start HTTP server
if err := r.Run(":8080"); err != nil {
log.WithError(err).Fatal("server failed to start")
}
```More info about the apex-log package [medium](https://medium.com/@tjholowaychuk/apex-log-e8d9627f4a9a)
TODO
* Apex log levels info/warning/error/fatal
* Unit-testing