Skip to content

Commit 61c4757

Browse files
Standardized logging for policy developers
1 parent 14978e3 commit 61c4757

File tree

20 files changed

+183
-218
lines changed

20 files changed

+183
-218
lines changed

cli/it/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/hashicorp/golang-lru v0.5.4 // indirect
1818
github.com/kr/pretty v0.3.1 // indirect
1919
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
20-
github.com/rogpeppe/go-internal v1.13.1 // indirect
20+
github.com/rogpeppe/go-internal v1.14.1 // indirect
2121
github.com/spf13/pflag v1.0.10 // indirect
2222
github.com/stretchr/testify v1.11.1 // indirect
2323
)

cli/it/go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
3838
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
3939
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4040
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
41-
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
42-
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
41+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
4342
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
4443
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
4544
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=

gateway/it/go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ require (
136136
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
137137
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
138138
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
139-
github.com/prometheus/client_golang v1.22.0 // indirect
139+
github.com/prometheus/client_golang v1.23.2 // indirect
140140
github.com/prometheus/client_model v0.6.2 // indirect
141-
github.com/prometheus/common v0.62.0 // indirect
142-
github.com/prometheus/procfs v0.15.1 // indirect
141+
github.com/prometheus/common v0.66.1 // indirect
142+
github.com/prometheus/procfs v0.16.1 // indirect
143143
github.com/rivo/uniseg v0.2.0 // indirect
144144
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
145145
github.com/secure-systems-lab/go-securesystemslib v0.6.0 // indirect
@@ -181,6 +181,7 @@ require (
181181
go.opentelemetry.io/otel/sdk/metric v1.39.0 // indirect
182182
go.opentelemetry.io/otel/trace v1.39.0 // indirect
183183
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
184+
go.yaml.in/yaml/v2 v2.4.2 // indirect
184185
go.yaml.in/yaml/v3 v3.0.4 // indirect
185186
golang.org/x/crypto v0.46.0 // indirect
186187
golang.org/x/net v0.48.0 // indirect

gateway/it/go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ github.com/prometheus/client_golang v0.9.0-pre1.0.20180209125602-c332b6f63c06/go
418418
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
419419
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
420420
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
421-
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
422-
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
421+
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
423422
github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
424423
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
425424
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -428,14 +427,12 @@ github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvM
428427
github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
429428
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
430429
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
431-
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
432-
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
430+
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
433431
github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
434432
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
435433
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
436434
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
437-
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
438-
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
435+
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
439436
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
440437
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
441438
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
@@ -572,6 +569,7 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
572569
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
573570
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
574571
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
572+
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
575573
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
576574
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
577575
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=

gateway/policies/api-key-auth/v0.1.0/apikey.go

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ const (
3535

3636
// APIKeyPolicy implements API Key Authentication
3737
type APIKeyPolicy struct {
38+
logger *slog.Logger
3839
}
3940

40-
var ins = &APIKeyPolicy{}
41-
4241
func GetPolicy(
4342
metadata policy.PolicyMetadata,
4443
params map[string]interface{},
44+
logger *slog.Logger,
4545
) (policy.Policy, error) {
46-
return ins, nil
46+
p := &APIKeyPolicy{
47+
logger: logger,
48+
}
49+
return p, nil
4750
}
4851

4952
// Mode returns the processing mode for this policy
@@ -58,7 +61,8 @@ func (p *APIKeyPolicy) Mode() policy.ProcessingMode {
5861

5962
// OnRequest performs API Key Authentication
6063
func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]interface{}) policy.RequestAction {
61-
slog.Debug("API Key Auth Policy: OnRequest started",
64+
log := policy.WithRequestID(p.logger, ctx.RequestID)
65+
log.Debug("OnRequest started",
6266
"path", ctx.Path,
6367
"method", ctx.Method,
6468
"apiId", ctx.APIId,
@@ -69,7 +73,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
6973
// Get configuration parameters
7074
keyName, ok := params["key"].(string)
7175
if !ok || keyName == "" {
72-
slog.Debug("API Key Auth Policy: Missing or invalid 'key' configuration",
76+
log.Debug("Missing or invalid 'key' configuration",
7377
"keyName", keyName,
7478
"ok", ok,
7579
)
@@ -79,7 +83,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
7983

8084
location, ok := params["in"].(string)
8185
if !ok || location == "" {
82-
slog.Debug("API Key Auth Policy: Missing or invalid 'in' configuration",
86+
log.Debug("Missing or invalid 'in' configuration",
8387
"location", location,
8488
"ok", ok,
8589
)
@@ -94,7 +98,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
9498
}
9599
}
96100

97-
slog.Debug("API Key Auth Policy: Configuration loaded",
101+
log.Debug("Configuration loaded",
98102
"keyName", keyName,
99103
"location", location,
100104
"valuePrefix", valuePrefix,
@@ -107,7 +111,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
107111
// Check header (case-insensitive)
108112
if headerValues := ctx.Headers.Get(http.CanonicalHeaderKey(keyName)); len(headerValues) > 0 {
109113
providedKey = headerValues[0]
110-
slog.Debug("API Key Auth Policy: Found API key in header",
114+
log.Debug("Found API key in header",
111115
"headerName", keyName,
112116
"keyLength", len(providedKey),
113117
)
@@ -116,7 +120,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
116120
// Extract query parameters from the full path
117121
providedKey = extractQueryParam(ctx.Path, keyName)
118122
if providedKey != "" {
119-
slog.Debug("API Key Auth Policy: Found API key in query parameter",
123+
log.Debug("Found API key in query parameter",
120124
"paramName", keyName,
121125
"keyLength", len(providedKey),
122126
)
@@ -125,7 +129,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
125129

126130
// If no API key provided
127131
if providedKey == "" {
128-
slog.Debug("API Key Auth Policy: No API key found",
132+
log.Debug("No API key found",
129133
"location", location,
130134
"keyName", keyName,
131135
)
@@ -137,15 +141,15 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
137141
if valuePrefix != "" {
138142
originalLength := len(providedKey)
139143
providedKey = stripPrefix(providedKey, valuePrefix)
140-
slog.Debug("API Key Auth Policy: Processed value prefix",
144+
log.Debug("Processed value prefix",
141145
"prefix", valuePrefix,
142146
"originalLength", originalLength,
143147
"processedLength", len(providedKey),
144148
)
145149

146150
// If after stripping prefix, the key is empty, treat as missing
147151
if providedKey == "" {
148-
slog.Debug("API Key Auth Policy: API key became empty after prefix removal")
152+
log.Debug("API key became empty after prefix removal")
149153
return p.handleAuthFailure(ctx, 401, "json", "Valid API key required",
150154
"missing API key")
151155
}
@@ -158,7 +162,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
158162
operationMethod := ctx.Method
159163

160164
if apiId == "" || apiName == "" || apiVersion == "" || apiOperation == "" || operationMethod == "" {
161-
slog.Debug("API Key Auth Policy: Missing API details for validation",
165+
log.Debug("Missing API details for validation",
162166
"apiId", apiId,
163167
"apiName", apiName,
164168
"apiVersion", apiVersion,
@@ -169,7 +173,7 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
169173
"missing API details for validation")
170174
}
171175

172-
slog.Debug("API Key Auth Policy: Starting validation",
176+
log.Debug("Starting validation",
173177
"apiId", apiId,
174178
"apiName", apiName,
175179
"apiVersion", apiVersion,
@@ -181,26 +185,27 @@ func (p *APIKeyPolicy) OnRequest(ctx *policy.RequestContext, params map[string]i
181185
// API key was provided - validate it using external validation
182186
isValid, err := p.validateAPIKey(apiId, apiOperation, operationMethod, providedKey)
183187
if err != nil {
184-
slog.Debug("API Key Auth Policy: Validation error",
188+
log.Debug("Validation error",
185189
"error", err,
186190
)
187191
return p.handleAuthFailure(ctx, 401, "json", "Valid API key required",
188192
"error validating API key")
189193
}
190194
if !isValid {
191-
slog.Debug("API Key Auth Policy: Invalid API key")
195+
log.Debug("Invalid API key")
192196
return p.handleAuthFailure(ctx, 401, "json", "Valid API key required",
193197
"invalid API key")
194198
}
195199

196200
// Authentication successful
197-
slog.Debug("API Key Auth Policy: Authentication successful")
201+
log.Debug("Authentication successful")
198202
return p.handleAuthSuccess(ctx)
199203
}
200204

201205
// handleAuthSuccess handles successful authentication
202206
func (p *APIKeyPolicy) handleAuthSuccess(ctx *policy.RequestContext) policy.RequestAction {
203-
slog.Debug("API Key Auth Policy: handleAuthSuccess called",
207+
log := policy.WithRequestID(p.logger, ctx.RequestID)
208+
log.Debug("handleAuthSuccess called",
204209
"apiId", ctx.APIId,
205210
"apiName", ctx.APIName,
206211
"apiVersion", ctx.APIVersion,
@@ -212,7 +217,7 @@ func (p *APIKeyPolicy) handleAuthSuccess(ctx *policy.RequestContext) policy.Requ
212217
ctx.Metadata[MetadataKeyAuthSuccess] = true
213218
ctx.Metadata[MetadataKeyAuthMethod] = "api-key"
214219

215-
slog.Debug("API Key Auth Policy: Authentication metadata set",
220+
log.Debug("Authentication metadata set",
216221
"authSuccess", true,
217222
"authMethod", "api-key",
218223
)
@@ -229,7 +234,8 @@ func (p *APIKeyPolicy) OnResponse(_ctx *policy.ResponseContext, _params map[stri
229234
// handleAuthFailure handles authentication failure
230235
func (p *APIKeyPolicy) handleAuthFailure(ctx *policy.RequestContext, statusCode int, errorFormat, errorMessage,
231236
reason string) policy.RequestAction {
232-
slog.Debug("API Key Auth Policy: handleAuthFailure called",
237+
log := policy.WithRequestID(p.logger, ctx.RequestID)
238+
log.Debug("handleAuthFailure called",
233239
"statusCode", statusCode,
234240
"errorFormat", errorFormat,
235241
"errorMessage", errorMessage,
@@ -263,7 +269,7 @@ func (p *APIKeyPolicy) handleAuthFailure(ctx *policy.RequestContext, statusCode
263269
body = string(bodyBytes)
264270
}
265271

266-
slog.Debug("API Key Auth Policy: Returning immediate response",
272+
log.Debug("Returning immediate response",
267273
"statusCode", statusCode,
268274
"contentType", headers["content-type"],
269275
"bodyLength", len(body),

gateway/policies/basic-auth/v0.1.0/basicauth.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package basicauth
33
import (
44
"encoding/base64"
55
"fmt"
6+
"log/slog"
67
"strings"
78

89
policy "github.com/wso2/api-platform/sdk/gateway/policy/v1alpha"
@@ -16,15 +17,19 @@ const (
1617
)
1718

1819
// BasicAuthPolicy implements HTTP Basic Authentication
19-
type BasicAuthPolicy struct{}
20-
21-
var ins = &BasicAuthPolicy{}
20+
type BasicAuthPolicy struct {
21+
logger *slog.Logger
22+
}
2223

2324
func GetPolicy(
2425
metadata policy.PolicyMetadata,
2526
params map[string]interface{},
27+
logger *slog.Logger,
2628
) (policy.Policy, error) {
27-
return ins, nil
29+
p := &BasicAuthPolicy{
30+
logger: logger,
31+
}
32+
return p, nil
2833
}
2934

3035
// Mode returns the processing mode for this policy

gateway/policies/content-length-guardrail/v0.1.0/contentlengthguardrail.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var textCleanRegexCompiled = regexp.MustCompile(TextCleanRegex)
2121

2222
// ContentLengthGuardrailPolicy implements content length validation
2323
type ContentLengthGuardrailPolicy struct {
24+
logger *slog.Logger
2425
hasRequestParams bool
2526
hasResponseParams bool
2627
requestParams ContentLengthGuardrailPolicyParams
@@ -38,8 +39,11 @@ type ContentLengthGuardrailPolicyParams struct {
3839
func GetPolicy(
3940
metadata policy.PolicyMetadata,
4041
params map[string]interface{},
42+
logger *slog.Logger,
4143
) (policy.Policy, error) {
42-
p := &ContentLengthGuardrailPolicy{}
44+
p := &ContentLengthGuardrailPolicy{
45+
logger: logger,
46+
}
4347

4448
// Extract and parse request parameters if present
4549
if requestParamsRaw, ok := params["request"].(map[string]interface{}); ok {
@@ -66,7 +70,7 @@ func GetPolicy(
6670
return nil, fmt.Errorf("at least one of 'request' or 'response' parameters must be provided")
6771
}
6872

69-
slog.Debug("ContentLengthGuardrail: Policy initialized", "hasRequestParams", p.hasRequestParams, "hasResponseParams", p.hasResponseParams)
73+
p.logger.Debug("Policy initialized", "hasRequestParams", p.hasRequestParams, "hasResponseParams", p.hasResponseParams)
7074

7175
return p, nil
7276
}
@@ -182,7 +186,7 @@ func (p *ContentLengthGuardrailPolicy) OnRequest(ctx *policy.RequestContext, par
182186
if ctx.Body != nil {
183187
content = ctx.Body.Content
184188
}
185-
return p.validatePayload(content, p.requestParams, false).(policy.RequestAction)
189+
return p.validatePayload(content, p.requestParams, false, ctx.RequestID).(policy.RequestAction)
186190
}
187191

188192
// OnResponse validates response body content length
@@ -195,15 +199,16 @@ func (p *ContentLengthGuardrailPolicy) OnResponse(ctx *policy.ResponseContext, p
195199
if ctx.ResponseBody != nil {
196200
content = ctx.ResponseBody.Content
197201
}
198-
return p.validatePayload(content, p.responseParams, true).(policy.ResponseAction)
202+
return p.validatePayload(content, p.responseParams, true, ctx.RequestID).(policy.ResponseAction)
199203
}
200204

201205
// validatePayload validates payload content length (request phase)
202-
func (p *ContentLengthGuardrailPolicy) validatePayload(payload []byte, params ContentLengthGuardrailPolicyParams, isResponse bool) interface{} {
206+
func (p *ContentLengthGuardrailPolicy) validatePayload(payload []byte, params ContentLengthGuardrailPolicyParams, isResponse bool, requestID string) interface{} {
207+
log := policy.WithRequestID(p.logger, requestID)
203208
// Extract value using JSONPath
204209
extractedValue, err := utils.ExtractStringValueFromJsonpath(payload, params.JsonPath)
205210
if err != nil {
206-
slog.Debug("ContentLengthGuardrail: Error extracting value from JSONPath", "jsonPath", params.JsonPath, "error", err, "isResponse", isResponse)
211+
log.Debug("Error extracting value from JSONPath", "jsonPath", params.JsonPath, "error", err, "isResponse", isResponse)
207212
return p.buildErrorResponse("Error extracting value from JSONPath", err, isResponse, params.ShowAssessment, params.Min, params.Max)
208213
}
209214

@@ -225,7 +230,7 @@ func (p *ContentLengthGuardrailPolicy) validatePayload(payload []byte, params Co
225230
}
226231

227232
if !validationPassed {
228-
slog.Debug("ContentLengthGuardrail: Validation failed", "byteCount", byteCount, "min", params.Min, "max", params.Max, "invert", params.Invert, "isResponse", isResponse)
233+
log.Debug("Validation failed", "byteCount", byteCount, "min", params.Min, "max", params.Max, "invert", params.Invert, "isResponse", isResponse)
229234
var reason string
230235
if params.Invert {
231236
reason = fmt.Sprintf("content length %d bytes is within the excluded range %d-%d bytes", byteCount, params.Min, params.Max)
@@ -235,7 +240,7 @@ func (p *ContentLengthGuardrailPolicy) validatePayload(payload []byte, params Co
235240
return p.buildErrorResponse(reason, nil, isResponse, params.ShowAssessment, params.Min, params.Max)
236241
}
237242

238-
slog.Debug("ContentLengthGuardrail: Validation passed", "byteCount", byteCount, "min", params.Min, "max", params.Max, "isResponse", isResponse)
243+
log.Debug("Validation passed", "byteCount", byteCount, "min", params.Min, "max", params.Max, "isResponse", isResponse)
239244
if isResponse {
240245
return policy.UpstreamResponseModifications{}
241246
}

0 commit comments

Comments
 (0)