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 (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -34,6 +35,7 @@ func (w *loggerResponseWriter) Flush() {
|
|||
}
|
||||
|
||||
func LogRequest(next http.Handler) http.Handler {
|
||||
stdout := log.New(os.Stdout, "", log.LstdFlags)
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
t := time.Now()
|
||||
logger := loggerResponseWriter{w, 0, 0}
|
||||
|
@ -45,7 +47,7 @@ func LogRequest(next http.Handler) http.Handler {
|
|||
if statusCode == 0 {
|
||||
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),
|
||||
r.Method,
|
||||
requestPath,
|
||||
|
|
Loading…
Reference in New Issue