Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
http: Ensure server loggers are not nil (fixes #2849)
Matthew Holt committed
Oct 31, 2019 at 11:45 UTC
fb06c041c4be4eb32f18d54e8e7feff8dd76b0e9
2 files changed
+7
-5
modules/caddyhttp/caddyhttp.go
+5
-3
@@ -479,9 +479,11 @@ func (app *App) automaticHTTPS() error {
479
// rest of the redirects
480
if len(redirServerAddrs) > 0 {
481
app.Servers["remaining_auto_https_redirects"] = &Server{
482
- Listen: redirServerAddrs,
483
- Routes: redirRoutes,
484
- tlsApp: tlsApp, // required to solve HTTP challenge
482
+ Listen: redirServerAddrs,
483
+ Routes: redirRoutes,
484
+ tlsApp: tlsApp, // required to solve HTTP challenge
485
+ logger: app.logger.Named("log"),
486
+ errorLogger: app.logger.Named("log.error"),
487
}
488
}
489
}
modules/caddyhttp/server.go
+2
-2
@@ -91,7 +91,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
91
zap.Object("request", loggableReq),
92
)
93
94
- if s.Logs != nil {
94
+ if s.accessLogger != nil {
95
wrec := NewResponseRecorder(w, nil, nil)
96
w = wrec
97
accLog := s.accessLogger.With(
@@ -107,7 +107,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
107
repl.Set("http.response.latency", latency.String())
108
109
logger := accLog
110
- if s.Logs.LoggerNames != nil {
110
+ if s.Logs != nil && s.Logs.LoggerNames != nil {
111
logger = logger.Named(s.Logs.LoggerNames[r.Host])
112
}
113