Skip to content

Commit 5917847

Browse files
authored
Fix RequestSize-related log names in routing middleware (dotnet#49740)
1 parent c1d3524 commit 5917847

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Http/Routing/src/EndpointRoutingMiddleware.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,18 @@ private void SetMaxRequestBodySize(HttpContext context)
304304
var sizeLimitMetadata = context.GetEndpoint()?.Metadata?.GetMetadata<IRequestSizeLimitMetadata>();
305305
if (sizeLimitMetadata == null)
306306
{
307-
Log.MetadataNotFound(_logger);
307+
Log.RequestSizeLimitMetadataNotFound(_logger);
308308
return;
309309
}
310310

311311
var maxRequestBodySizeFeature = context.Features.Get<IHttpMaxRequestBodySizeFeature>();
312312
if (maxRequestBodySizeFeature == null)
313313
{
314-
Log.FeatureNotFound(_logger);
314+
Log.RequestSizeFeatureNotFound(_logger);
315315
}
316316
else if (maxRequestBodySizeFeature.IsReadOnly)
317317
{
318-
Log.FeatureIsReadOnly(_logger);
318+
Log.RequestSizeFeatureIsReadOnly(_logger);
319319
}
320320
else
321321
{
@@ -363,14 +363,14 @@ public static void MatchSkipped(ILogger logger, Endpoint endpoint)
363363
[LoggerMessage(7, LogLevel.Debug, "Matched endpoint '{EndpointName}' is a fallback endpoint.", EventName = "FallbackMatch")]
364364
public static partial void FallbackMatch(ILogger logger, Endpoint endpointName);
365365

366-
[LoggerMessage(8, LogLevel.Debug, $"The endpoint does not specify the {nameof(IRequestSizeLimitMetadata)}.", EventName = "MetadataNotFound")]
367-
public static partial void MetadataNotFound(ILogger logger);
366+
[LoggerMessage(8, LogLevel.Trace, $"The endpoint does not specify the {nameof(IRequestSizeLimitMetadata)}.", EventName = "RequestSizeLimitMetadataNotFound")]
367+
public static partial void RequestSizeLimitMetadataNotFound(ILogger logger);
368368

369-
[LoggerMessage(9, LogLevel.Warning, $"A request body size limit could not be applied. This server does not support the {nameof(IHttpMaxRequestBodySizeFeature)}.", EventName = "FeatureNotFound")]
370-
public static partial void FeatureNotFound(ILogger logger);
369+
[LoggerMessage(9, LogLevel.Warning, $"A request body size limit could not be applied. This server does not support the {nameof(IHttpMaxRequestBodySizeFeature)}.", EventName = "RequestSizeFeatureNotFound")]
370+
public static partial void RequestSizeFeatureNotFound(ILogger logger);
371371

372-
[LoggerMessage(10, LogLevel.Warning, $"A request body size limit could not be applied. The {nameof(IHttpMaxRequestBodySizeFeature)} for the server is read-only.", EventName = "FeatureIsReadOnly")]
373-
public static partial void FeatureIsReadOnly(ILogger logger);
372+
[LoggerMessage(10, LogLevel.Warning, $"A request body size limit could not be applied. The {nameof(IHttpMaxRequestBodySizeFeature)} for the server is read-only.", EventName = "RequestSizeFeatureIsReadOnly")]
373+
public static partial void RequestSizeFeatureIsReadOnly(ILogger logger);
374374

375375
[LoggerMessage(11, LogLevel.Debug, "The maximum request body size has been set to {RequestSize}.", EventName = "MaxRequestBodySizeSet")]
376376
public static partial void MaxRequestBodySizeSet(ILogger logger, string requestSize);

src/Http/Routing/test/UnitTests/EndpointRoutingMiddlewareTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public async Task Endpoint_BodySizeFeatureIsReadOnly()
289289
await middleware.Invoke(httpContext);
290290

291291
// Assert
292-
var write = Assert.Single(sink.Writes.Where(w => w.EventId.Name == "FeatureIsReadOnly"));
292+
var write = Assert.Single(sink.Writes.Where(w => w.EventId.Name == "RequestSizeFeatureIsReadOnly"));
293293
Assert.Equal($"A request body size limit could not be applied. The {nameof(IHttpMaxRequestBodySizeFeature)} for the server is read-only.", write.Message);
294294

295295
var actualRequestSizeLimit = maxRequestBodySizeFeature.MaxRequestBodySize;
@@ -318,7 +318,7 @@ public async Task Endpoint_DoesNotHaveBodySizeFeature()
318318
await middleware.Invoke(httpContext);
319319

320320
// Assert
321-
var write = Assert.Single(sink.Writes.Where(w => w.EventId.Name == "FeatureNotFound"));
321+
var write = Assert.Single(sink.Writes.Where(w => w.EventId.Name == "RequestSizeFeatureNotFound"));
322322
Assert.Equal($"A request body size limit could not be applied. This server does not support the {nameof(IHttpMaxRequestBodySizeFeature)}.", write.Message);
323323
}
324324

@@ -346,7 +346,7 @@ public async Task Endpoint_DoesNotHaveSizeLimitMetadata()
346346
await middleware.Invoke(httpContext);
347347

348348
// Assert
349-
var write = Assert.Single(sink.Writes.Where(w => w.EventId.Name == "MetadataNotFound"));
349+
var write = Assert.Single(sink.Writes.Where(w => w.EventId.Name == "RequestSizeLimitMetadataNotFound"));
350350
Assert.Equal($"The endpoint does not specify the {nameof(IRequestSizeLimitMetadata)}.", write.Message);
351351
}
352352

0 commit comments

Comments
 (0)