mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
http: Ensure server loggers are not nil (fixes #2849)
This commit is contained in:
parent
8ef0a0b4f8
commit
fb06c041c4
2 changed files with 7 additions and 5 deletions
|
@ -479,9 +479,11 @@ func (app *App) automaticHTTPS() error {
|
||||||
// rest of the redirects
|
// rest of the redirects
|
||||||
if len(redirServerAddrs) > 0 {
|
if len(redirServerAddrs) > 0 {
|
||||||
app.Servers["remaining_auto_https_redirects"] = &Server{
|
app.Servers["remaining_auto_https_redirects"] = &Server{
|
||||||
Listen: redirServerAddrs,
|
Listen: redirServerAddrs,
|
||||||
Routes: redirRoutes,
|
Routes: redirRoutes,
|
||||||
tlsApp: tlsApp, // required to solve HTTP challenge
|
tlsApp: tlsApp, // required to solve HTTP challenge
|
||||||
|
logger: app.logger.Named("log"),
|
||||||
|
errorLogger: app.logger.Named("log.error"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
zap.Object("request", loggableReq),
|
zap.Object("request", loggableReq),
|
||||||
)
|
)
|
||||||
|
|
||||||
if s.Logs != nil {
|
if s.accessLogger != nil {
|
||||||
wrec := NewResponseRecorder(w, nil, nil)
|
wrec := NewResponseRecorder(w, nil, nil)
|
||||||
w = wrec
|
w = wrec
|
||||||
accLog := s.accessLogger.With(
|
accLog := s.accessLogger.With(
|
||||||
|
@ -107,7 +107,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
repl.Set("http.response.latency", latency.String())
|
repl.Set("http.response.latency", latency.String())
|
||||||
|
|
||||||
logger := accLog
|
logger := accLog
|
||||||
if s.Logs.LoggerNames != nil {
|
if s.Logs != nil && s.Logs.LoggerNames != nil {
|
||||||
logger = logger.Named(s.Logs.LoggerNames[r.Host])
|
logger = logger.Named(s.Logs.LoggerNames[r.Host])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue