Actually log request to stdout to be captured by systemd
This commit is contained in:
parent
9dc4c4ef8d
commit
334904fc03
|
@ -8,6 +8,7 @@ package http
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ func (w *loggerResponseWriter) Flush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogRequest(next http.Handler) http.Handler {
|
func LogRequest(next http.Handler) http.Handler {
|
||||||
|
stdout := log.New(os.Stdout, "", log.LstdFlags)
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
logger := loggerResponseWriter{w, 0, 0}
|
logger := loggerResponseWriter{w, 0, 0}
|
||||||
|
@ -45,7 +47,7 @@ func LogRequest(next http.Handler) http.Handler {
|
||||||
if statusCode == 0 {
|
if statusCode == 0 {
|
||||||
statusCode = http.StatusOK
|
statusCode = http.StatusOK
|
||||||
}
|
}
|
||||||
log.Printf("HTTP - %s %s \"%s\" %d %d %s\n",
|
stdout.Printf("HTTP - %s %s \"%s\" %d %d %s\n",
|
||||||
RemoteAddr(r),
|
RemoteAddr(r),
|
||||||
r.Method,
|
r.Method,
|
||||||
requestPath,
|
requestPath,
|
||||||
|
|
Loading…
Reference in New Issue