HTTP logger middleware for Go
go get -u github.com/go-http-utils/logger
https://godoc.org/github.com/go-http-utils/logger
import (
"net/http"
"os"
"github.com/go-http-utils/logger"
)
mux := http.NewServeMux()
mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
res.Write([]byte("Hello World"))
})
http.ListenAndServe(":8080", logger.Handler(mux, os.Stdout, logger.DevLoggerType))
CombineLoggerType is the standard Apache combined log output
:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"
CommonLoggerType is the standard Apache common log output
:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length]
DevLoggerType is useful for development
:method :url :status :response-time ms - :res[content-length]
ShortLoggerType is shorter than common, including response time
:remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms
TinyLoggerType is the minimal ouput
:method :url :status :res[content-length] - :response-time ms