mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
log: Store http request/responses in a log file (#4804)
When MINIO_TRACE_DIR is provided, create a new log file and store all HTTP requests + responses data, body are excluded to reduce memory consumption. MINIO_HTTP_TRACE=1 enables logging. Use non mem consuming http req/resp recorders, the maximum is about 32k per request. This logs to STDOUT, body logging is disabled for PutObject PutObjectPart GetObject.
This commit is contained in:
@@ -21,7 +21,10 @@ import (
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
httptracer "github.com/minio/minio/pkg/handlers"
|
||||
)
|
||||
|
||||
// Parses location constraint from the incoming reader.
|
||||
@@ -240,3 +243,19 @@ func extractPostPolicyFormValues(form *multipart.Form) (filePart io.ReadCloser,
|
||||
|
||||
return filePart, fileName, fileSize, formValues, nil
|
||||
}
|
||||
|
||||
// Log headers and body.
|
||||
func httpTraceAll(f http.HandlerFunc) http.HandlerFunc {
|
||||
if !globalHTTPTrace {
|
||||
return f
|
||||
}
|
||||
return httptracer.TraceReqHandlerFunc(f, os.Stdout, true)
|
||||
}
|
||||
|
||||
// Log only the headers.
|
||||
func httpTraceHdrs(f http.HandlerFunc) http.HandlerFunc {
|
||||
if !globalHTTPTrace {
|
||||
return f
|
||||
}
|
||||
return httptracer.TraceReqHandlerFunc(f, os.Stdout, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user