summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-03-19 13:42:26 -0400
committerGitHub <noreply@github.com>2021-03-19 11:42:26 -0600
commit0018b9be0d2e409cd80367c9e8403188723d0996 (patch)
treeb2a758dfc84dd7829229f87b7b2b5c8c30c1d194 /modules/caddyhttp
parenta48c6205b79c80ec28eb791d144275da8669dc6e (diff)
fileserver: Add a few more debug lines (#4063)
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index e809f49..f58dfe0 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -295,8 +295,10 @@ func (fsrv *FileServer) openFile(filename string, w http.ResponseWriter) (*os.Fi
if err != nil {
err = mapDirOpenError(err, filename)
if os.IsNotExist(err) {
+ fsrv.logger.Debug("file not found", zap.String("filename", filename), zap.Error(err))
return nil, caddyhttp.Error(http.StatusNotFound, err)
} else if os.IsPermission(err) {
+ fsrv.logger.Debug("permission denied", zap.String("filename", filename), zap.Error(err))
return nil, caddyhttp.Error(http.StatusForbidden, err)
}
// maybe the server is under load and ran out of file descriptors?
@@ -304,6 +306,7 @@ func (fsrv *FileServer) openFile(filename string, w http.ResponseWriter) (*os.Fi
//nolint:gosec
backoff := weakrand.Intn(maxBackoff-minBackoff) + minBackoff
w.Header().Set("Retry-After", strconv.Itoa(backoff))
+ fsrv.logger.Debug("retry after backoff", zap.String("filename", filename), zap.Int("backoff", backoff), zap.Error(err))
return nil, caddyhttp.Error(http.StatusServiceUnavailable, err)
}
return file, nil