https://github.com/pytimer/mux-logrus
logrus middleware for groilla/mux
https://github.com/pytimer/mux-logrus
golang logrus middleware mux
Last synced: 5 months ago
JSON representation
logrus middleware for groilla/mux
- Host: GitHub
- URL: https://github.com/pytimer/mux-logrus
- Owner: pytimer
- License: mit
- Created: 2018-04-10T03:21:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-05T08:58:08.000Z (about 6 years ago)
- Last Synced: 2025-08-14T02:36:25.423Z (10 months ago)
- Topics: golang, logrus, middleware, mux
- Language: Go
- Size: 4.88 KB
- Stars: 10
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mux-logrus
==============
[](https://godoc.org/github.com/pytimer/mux-logrus)
logrus middleware for gorilla/mux
## Getting Started
```go
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/pytimer/mux-logrus"
)
func index(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello!"))
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/hello", index).Methods(http.MethodGet)
// add logger middleware
r.Use(muxlogrus.NewLogger().Middleware)
address := ":8990"
log.Printf("Listen on address %s", address)
http.ListenAndServe(address, r)
}
```
output log:
```sh
time="2018-04-10T11:10:39+08:00" level=info msg="completed handling request" remoteAddr=127.0.0.1 status=400 took="6.838µs"
```