Log Apache access_log-like entries at Info level [NO NEW TESTS NEEDED]

Only log API access entries when --log-level set to Info or below.

Fixes #12181

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce 2021-11-05 10:12:32 -07:00
parent 9b3b44903d
commit 5c0351cc6f
1 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package server
import (
"fmt"
"io/ioutil"
"net/http"
"github.com/containers/podman/v3/pkg/api/types"
@ -15,7 +16,13 @@ import (
// and Apache style request logging
func referenceIDHandler() mux.MiddlewareFunc {
return func(h http.Handler) http.Handler {
return handlers.CombinedLoggingHandler(logrus.StandardLogger().Out,
// Only log Apache access_log-like entries at Info level or below
out := ioutil.Discard
if logrus.IsLevelEnabled(logrus.InfoLevel) {
out = logrus.StandardLogger().Out
}
return handlers.CombinedLoggingHandler(out,
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
rid := r.Header.Get("X-Reference-Id")
if rid == "" {