@@ -54,8 +54,8 @@ internal static class MvcCoreLoggerExtensions
5454 private static readonly Action < ILogger , string , Exception > _ambiguousActions ;
5555 private static readonly Action < ILogger , string , string , IActionConstraint , Exception > _constraintMismatch ;
5656
57- private static readonly Action < ILogger , FileResult , string , string , Exception > _executingFileResult ;
58- private static readonly Action < ILogger , FileResult , string , Exception > _executingFileResultWithNoFileName ;
57+ private static readonly Action < ILogger , string , string , string , Exception > _executingFileResult ;
58+ private static readonly Action < ILogger , string , string , Exception > _executingFileResultWithNoFileName ;
5959 private static readonly Action < ILogger , Exception > _notEnabledForRangeProcessing ;
6060 private static readonly Action < ILogger , Exception > _writingRangeToBody ;
6161 private static readonly Action < ILogger , object , Exception > _authorizationFailure ;
@@ -72,7 +72,7 @@ internal static class MvcCoreLoggerExtensions
7272
7373 private static readonly Action < ILogger , string , Exception > _localRedirectResultExecuting ;
7474
75- private static readonly Action < ILogger , string , Exception > _objectResultExecuting ;
75+ private static readonly Action < ILogger , string , string , Exception > _objectResultExecuting ;
7676 private static readonly Action < ILogger , IEnumerable < string > , Exception > _noFormatter ;
7777 private static readonly Action < ILogger , IOutputFormatter , string , Exception > _formatterSelected ;
7878 private static readonly Action < ILogger , string , Exception > _skippedContentNegotiation ;
@@ -250,12 +250,12 @@ static MvcCoreLoggerExtensions()
250250 new EventId ( 2 , "ConstraintMismatch" ) ,
251251 "Action '{ActionName}' with id '{ActionId}' did not match the constraint '{ActionConstraint}'" ) ;
252252
253- _executingFileResult = LoggerMessage . Define < FileResult , string , string > (
253+ _executingFileResult = LoggerMessage . Define < string , string , string > (
254254 LogLevel . Information ,
255255 new EventId ( 1 , "ExecutingFileResult" ) ,
256256 "Executing {FileResultType}, sending file '{FileDownloadPath}' with download name '{FileDownloadName}' ..." ) ;
257257
258- _executingFileResultWithNoFileName = LoggerMessage . Define < FileResult , string > (
258+ _executingFileResultWithNoFileName = LoggerMessage . Define < string , string > (
259259 LogLevel . Information ,
260260 new EventId ( 2 , "ExecutingFileResultWithNoFileName" ) ,
261261 "Executing {FileResultType}, sending file with download name '{FileDownloadName}' ..." ) ;
@@ -315,10 +315,10 @@ static MvcCoreLoggerExtensions()
315315 new EventId ( 1 , "NoFormatter" ) ,
316316 "No output formatter was found for content types '{ContentTypes}' to write the response." ) ;
317317
318- _objectResultExecuting = LoggerMessage . Define < string > (
318+ _objectResultExecuting = LoggerMessage . Define < string , string > (
319319 LogLevel . Information ,
320320 new EventId ( 1 , "ObjectResultExecuting" ) ,
321- "Executing ObjectResult , writing value of type '{Type}'." ) ;
321+ "Executing {ObjectResultType} , writing value of type '{Type}'." ) ;
322322
323323 _formatterSelected = LoggerMessage . Define < IOutputFormatter , string > (
324324 LogLevel . Debug ,
@@ -933,12 +933,20 @@ public static void ConstraintMismatch(
933933
934934 public static void ExecutingFileResult ( this ILogger logger , FileResult fileResult )
935935 {
936- _executingFileResultWithNoFileName ( logger , fileResult , fileResult . FileDownloadName , null ) ;
936+ if ( logger . IsEnabled ( LogLevel . Information ) )
937+ {
938+ var fileResultType = fileResult . GetType ( ) . Name ;
939+ _executingFileResultWithNoFileName ( logger , fileResultType , fileResult . FileDownloadName , null ) ;
940+ }
937941 }
938942
939943 public static void ExecutingFileResult ( this ILogger logger , FileResult fileResult , string fileName )
940944 {
941- _executingFileResult ( logger , fileResult , fileName , fileResult . FileDownloadName , null ) ;
945+ if ( logger . IsEnabled ( LogLevel . Information ) )
946+ {
947+ var fileResultType = fileResult . GetType ( ) . Name ;
948+ _executingFileResult ( logger , fileResultType , fileName , fileResult . FileDownloadName , null ) ;
949+ }
942950 }
943951
944952 public static void NotEnabledForRangeProcessing ( this ILogger logger )
@@ -1017,12 +1025,13 @@ public static void LocalRedirectResultExecuting(this ILogger logger, string dest
10171025 _localRedirectResultExecuting ( logger , destination , null ) ;
10181026 }
10191027
1020- public static void ObjectResultExecuting ( this ILogger logger , object value )
1028+ public static void ObjectResultExecuting ( this ILogger logger , ObjectResult result , object value )
10211029 {
10221030 if ( logger . IsEnabled ( LogLevel . Information ) )
10231031 {
1024- var type = value == null ? "null" : value . GetType ( ) . FullName ;
1025- _objectResultExecuting ( logger , type , null ) ;
1032+ var objectResultType = result . GetType ( ) . Name ;
1033+ var valueType = value == null ? "null" : value . GetType ( ) . FullName ;
1034+ _objectResultExecuting ( logger , objectResultType , valueType , null ) ;
10261035 }
10271036 }
10281037
0 commit comments