Skip to content

Commit af6b13f

Browse files
committed
Use MapActionEndpointRouteBuilderExtensions for logger category
1 parent 6a31ec8 commit af6b13f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/Http/Routing/src/Internal/MapActionExpressionTreeBuilder.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Reflection;
1212
using System.Threading;
1313
using System.Threading.Tasks;
14+
using Microsoft.AspNetCore.Builder;
1415
using Microsoft.AspNetCore.Http;
1516
using Microsoft.AspNetCore.Http.Metadata;
1617
using Microsoft.Extensions.DependencyInjection;
@@ -319,12 +320,7 @@ public static RequestDelegate BuildRequestDelegate(Delegate action)
319320
private static void LogRequestBodyIOException(HttpContext httpContext, IOException exception)
320321
{
321322
var loggerFactory = httpContext.RequestServices.GetRequiredService<ILoggerFactory>();
322-
323-
// REVIEW: I'm not sure how we feel about using an internal type as a category name, but this is what was done in other
324-
// internal classes like DfaMather and DefaultLinkGenerator. My main concern is if we want to use the same category for
325-
// other MapAction implementations (e.g. Roslyn source generators)
326-
var logger = loggerFactory.CreateLogger(typeof(MapActionExpressionTreeBuilder).FullName!);
327-
323+
var logger = loggerFactory.CreateLogger(typeof(MapActionEndpointRouteBuilderExtensions).FullName!);
328324
Log.RequestBodyIOException(logger, exception);
329325
}
330326

src/Http/Routing/test/UnitTests/Internal/MapActionExpressionTreeBuilderTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Text.Json;
1212
using System.Threading;
1313
using System.Threading.Tasks;
14+
using Microsoft.AspNetCore.Builder;
1415
using Microsoft.AspNetCore.Http;
1516
using Microsoft.AspNetCore.Http.Features;
1617
using Microsoft.AspNetCore.Http.Metadata;
@@ -256,7 +257,7 @@ public async Task RequestDelegateLogsFromBodyIOExceptionsAsDebug()
256257
{
257258
var invoked = false;
258259

259-
var sink = new TestSink(context => context.LoggerName == typeof(MapActionExpressionTreeBuilder).FullName);
260+
var sink = new TestSink(context => context.LoggerName == typeof(MapActionEndpointRouteBuilderExtensions).FullName);
260261
var testLoggerFactory = new TestLoggerFactory(sink, enabled: true);
261262

262263
void TestAction([FromBody] Todo todo)
@@ -320,7 +321,7 @@ public async Task RequestDelegateLogsFromFormIOExceptionsAsDebug()
320321
{
321322
var invoked = false;
322323

323-
var sink = new TestSink(context => context.LoggerName == typeof(MapActionExpressionTreeBuilder).FullName);
324+
var sink = new TestSink(context => context.LoggerName == typeof(MapActionEndpointRouteBuilderExtensions).FullName);
324325
var testLoggerFactory = new TestLoggerFactory(sink, enabled: true);
325326

326327
void TestAction([FromForm] int value)

0 commit comments

Comments
 (0)