Skip to content
Permalink
Browse files

http: Only enable access logs if configured

  • Loading branch information
mholt committed Nov 16, 2019
1 parent 8025ad9 commit af26a03da1af7cd7d64fc03270961829d0311ed7
Showing with 6 additions and 1 deletion.
  1. +5 −1 modules/caddyhttp/caddyhttp.go
  2. +1 −0 modules/caddyhttp/responsewriter.go
@@ -76,9 +76,13 @@ func (app *App) Provision(ctx caddy.Context) error {

for srvName, srv := range app.Servers {
srv.logger = app.logger.Named("log")
srv.accessLogger = app.logger.Named("log.access")
srv.errorLogger = app.logger.Named("log.error")

// only enable access logs if configured
if srv.Logs != nil {
srv.accessLogger = app.logger.Named("log.access")
}

if srv.AutoHTTPS == nil {
// avoid nil pointer dereferences
srv.AutoHTTPS = new(AutoHTTPSConfig)
@@ -229,6 +229,7 @@ func (rr *responseRecorder) WriteResponse() error {
_, err := io.Copy(rr.ResponseWriterWrapper, rr.buf)
return err
}

// ResponseRecorder is a http.ResponseWriter that records
// responses instead of writing them to the client. See
// docs for NewResponseRecorder for proper usage.

0 comments on commit af26a03

Please sign in to comment.
You can’t perform that action at this time.