shouldLogRequest returns true if this request should be logged.
(r *http.Request)
| 801 | |
| 802 | // shouldLogRequest returns true if this request should be logged. |
| 803 | func (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. |