caddyhttp: Add uuid to access logs when used (#5859)

This commit is contained in:
Francis Lavoie
2023-12-13 17:40:15 -05:00
committed by GitHub
parent dc12bd9743
commit 3d7d60f7cf
3 changed files with 22 additions and 0 deletions

View File

@@ -151,6 +151,18 @@ func (e *ExtraLogFields) Add(field zap.Field) {
e.fields = append(e.fields, field)
}
// Set sets a field in the list of extra fields to log.
// If the field already exists, it is replaced.
func (e *ExtraLogFields) Set(field zap.Field) {
for i := range e.fields {
if e.fields[i].Key == field.Key {
e.fields[i] = field
return
}
}
e.fields = append(e.fields, field)
}
const (
// Variable name used to indicate that this request
// should be omitted from the access logs