@@ -54,8 +54,8 @@ internal static class MvcCoreLoggerExtensions
54
54
private static readonly Action < ILogger , string , Exception > _ambiguousActions ;
55
55
private static readonly Action < ILogger , string , string , IActionConstraint , Exception > _constraintMismatch ;
56
56
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 ;
59
59
private static readonly Action < ILogger , Exception > _notEnabledForRangeProcessing ;
60
60
private static readonly Action < ILogger , Exception > _writingRangeToBody ;
61
61
private static readonly Action < ILogger , object , Exception > _authorizationFailure ;
@@ -72,7 +72,7 @@ internal static class MvcCoreLoggerExtensions
72
72
73
73
private static readonly Action < ILogger , string , Exception > _localRedirectResultExecuting ;
74
74
75
- private static readonly Action < ILogger , string , Exception > _objectResultExecuting ;
75
+ private static readonly Action < ILogger , string , string , Exception > _objectResultExecuting ;
76
76
private static readonly Action < ILogger , IEnumerable < string > , Exception > _noFormatter ;
77
77
private static readonly Action < ILogger , IOutputFormatter , string , Exception > _formatterSelected ;
78
78
private static readonly Action < ILogger , string , Exception > _skippedContentNegotiation ;
@@ -250,12 +250,12 @@ static MvcCoreLoggerExtensions()
250
250
new EventId ( 2 , "ConstraintMismatch" ) ,
251
251
"Action '{ActionName}' with id '{ActionId}' did not match the constraint '{ActionConstraint}'" ) ;
252
252
253
- _executingFileResult = LoggerMessage . Define < FileResult , string , string > (
253
+ _executingFileResult = LoggerMessage . Define < string , string , string > (
254
254
LogLevel . Information ,
255
255
new EventId ( 1 , "ExecutingFileResult" ) ,
256
256
"Executing {FileResultType}, sending file '{FileDownloadPath}' with download name '{FileDownloadName}' ..." ) ;
257
257
258
- _executingFileResultWithNoFileName = LoggerMessage . Define < FileResult , string > (
258
+ _executingFileResultWithNoFileName = LoggerMessage . Define < string , string > (
259
259
LogLevel . Information ,
260
260
new EventId ( 2 , "ExecutingFileResultWithNoFileName" ) ,
261
261
"Executing {FileResultType}, sending file with download name '{FileDownloadName}' ..." ) ;
@@ -315,10 +315,10 @@ static MvcCoreLoggerExtensions()
315
315
new EventId ( 1 , "NoFormatter" ) ,
316
316
"No output formatter was found for content types '{ContentTypes}' to write the response." ) ;
317
317
318
- _objectResultExecuting = LoggerMessage . Define < string > (
318
+ _objectResultExecuting = LoggerMessage . Define < string , string > (
319
319
LogLevel . Information ,
320
320
new EventId ( 1 , "ObjectResultExecuting" ) ,
321
- "Executing ObjectResult , writing value of type '{Type}'." ) ;
321
+ "Executing {ObjectResultType} , writing value of type '{Type}'." ) ;
322
322
323
323
_formatterSelected = LoggerMessage . Define < IOutputFormatter , string > (
324
324
LogLevel . Debug ,
@@ -933,12 +933,20 @@ public static void ConstraintMismatch(
933
933
934
934
public static void ExecutingFileResult ( this ILogger logger , FileResult fileResult )
935
935
{
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
+ }
937
941
}
938
942
939
943
public static void ExecutingFileResult ( this ILogger logger , FileResult fileResult , string fileName )
940
944
{
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
+ }
942
950
}
943
951
944
952
public static void NotEnabledForRangeProcessing ( this ILogger logger )
@@ -1017,12 +1025,13 @@ public static void LocalRedirectResultExecuting(this ILogger logger, string dest
1017
1025
_localRedirectResultExecuting ( logger , destination , null ) ;
1018
1026
}
1019
1027
1020
- public static void ObjectResultExecuting ( this ILogger logger , object value )
1028
+ public static void ObjectResultExecuting ( this ILogger logger , ObjectResult result , object value )
1021
1029
{
1022
1030
if ( logger . IsEnabled ( LogLevel . Information ) )
1023
1031
{
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 ) ;
1026
1035
}
1027
1036
}
1028
1037
0 commit comments