MCPcopy
hub / github.com/caddyserver/caddy / shouldLogRequest

Method shouldLogRequest

modules/caddyhttp/server.go:803–829  ·  view source on GitHub ↗

shouldLogRequest returns true if this request should be logged.

(r *http.Request)

Source from the content-addressed store, hash-verified

801
802// shouldLogRequest returns true if this request should be logged.
803func (s *Server) shouldLogRequest(r *http.Request) bool {
804 if s.accessLogger == nil || s.Logs == nil {
805 // logging is disabled
806 return false
807 }
808
809 // strip off the port if any, logger names are host only
810 hostWithoutPort, _, err := net.SplitHostPort(r.Host)
811 if err != nil {
812 hostWithoutPort = r.Host
813 }
814
815 for loggerName := range s.Logs.LoggerNames {
816 if certmagic.MatchWildcard(hostWithoutPort, loggerName) {
817 // this host is mapped to a particular logger name
818 return true
819 }
820 }
821 for _, dh := range s.Logs.SkipHosts {
822 // logging for this particular host is disabled
823 if certmagic.MatchWildcard(hostWithoutPort, dh) {
824 return false
825 }
826 }
827 // if configured, this host is not mapped and thus must not be logged
828 return !s.Logs.SkipUnmappedHosts
829}
830
831// logTrace will log that this middleware handler is being invoked.
832// It emits at DEBUG level.

Callers 2

ServeHTTPMethod · 0.95
serveHTTPMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected