summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/logging.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/logging.go')
-rw-r--r--modules/caddyhttp/logging.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/modules/caddyhttp/logging.go b/modules/caddyhttp/logging.go
index 4faaec7..8ecc49a 100644
--- a/modules/caddyhttp/logging.go
+++ b/modules/caddyhttp/logging.go
@@ -22,6 +22,8 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
+
+ "github.com/caddyserver/caddy/v2"
)
// ServerLogConfig describes a server's logging configuration. If
@@ -139,6 +141,21 @@ func errLogValues(err error) (status int, msg string, fields []zapcore.Field) {
return
}
-// Variable name used to indicate that this request
-// should be omitted from the access logs
-const SkipLogVar = "skip_log"
+// ExtraLogFields is a list of extra fields to log with every request.
+type ExtraLogFields struct {
+ fields []zapcore.Field
+}
+
+// Add adds a field to the list of extra fields to log.
+func (e *ExtraLogFields) Add(field zap.Field) {
+ e.fields = append(e.fields, field)
+}
+
+const (
+ // Variable name used to indicate that this request
+ // should be omitted from the access logs
+ SkipLogVar string = "skip_log"
+
+ // For adding additional fields to the access logs
+ ExtraLogFieldsCtxKey caddy.CtxKey = "extra_log_fields"
+)