Log requests in a go webserver.
THis library will log all HTTP-Requests in a golang webserver. This comes in handy if you want global request-logging enabled. Building the log-messages is done via logrus.
- with go-get:
go get github.com/fr3dch3n/goreq-logging
- with dep:
dep ensure --add github.com/fr3dch3n/goreq-logging
Enable JSON-logging
package main
import (
logHandler "github.com/fr3dch3n/goreq-logging"
log "github.com/sirupsen/logrus"
"net/http"
)
func main() {
log.SetFormatter(&log.JSONFormatter{})
err := http.ListenAndServe(":80", logHandler.LogRequests(http.DefaultServeMux))
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
- 0.0.1
- initial release
Distributed under the Apache 2.0 license. See LICENSE
for more information.
- Fork it (https://github.com/fr3dch3n/goreq-logging/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request