Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 100 additions & 99 deletions src/Microsoft.AspNetCore.Mvc.Core/MvcCoreLoggerExtensions.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Mvc.Cors/CorsLoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static CorsLoggerExtensions()
{
_notMostEffectiveFilter = LoggerMessage.Define<Type>(
LogLevel.Debug,
1,
new EventId(1, nameof(NotMostEffectiveFilter)),
"Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ static MvcJsonLoggerExtensions()
{
_jsonInputFormatterCrashed = LoggerMessage.Define(
LogLevel.Debug,
1,
new EventId(1, nameof(JsonInputException)),
"JSON input formatter threw an exception.");

_jsonResultExecuting = LoggerMessage.Define<string>(
LogLevel.Information,
1,
new EventId(1, nameof(JsonResultExecuting)),
"Executing JsonResult, writing value of type '{Type}'.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ static LoggerExtensions()
{
_failedToCreateXmlSerializer = LoggerMessage.Define<string>(
LogLevel.Warning,
1,
new EventId(1, nameof(FailedToCreateXmlSerializer)),
"An error occurred while trying to create an XmlSerializer for the type '{Type}'.");

_failedToCreateDataContractSerializer = LoggerMessage.Define<string>(
LogLevel.Warning,
2,
new EventId(2, nameof(FailedToCreateDataContractSerializer)),
"An error occurred while trying to create a DataContractSerializer for the type '{Type}'.");
}

public static void FailedToCreateXmlSerializer(this ILogger logger, string typeName, Exception exception)
{
_failedToCreateXmlSerializer(logger, typeName, exception);
}

public static void FailedToCreateDataContractSerializer(this ILogger logger, string typeName, Exception exception)
{
_failedToCreateDataContractSerializer(logger, typeName, exception);
Expand Down
37 changes: 16 additions & 21 deletions src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorLoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,87 +36,82 @@ static MvcRazorLoggerExtensions()
{
_viewCompilerStartCodeGeneration = LoggerMessage.Define<string>(
LogLevel.Debug,
1,
new EventId(1, nameof(ViewCompilerStartCodeGeneration)),
"Code generation for the Razor file at '{FilePath}' started.");

_viewCompilerEndCodeGeneration = LoggerMessage.Define<string, double>(
LogLevel.Debug,
2,
new EventId(2, nameof(ViewCompilerEndCodeGeneration)),
"Code generation for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms.");

_viewCompilerLocatedCompiledView = LoggerMessage.Define<string>(
LogLevel.Debug,
3,
new EventId(3, nameof(ViewCompilerLocatedCompiledView)),
"Initializing Razor view compiler with compiled view: '{ViewName}'.");

_viewCompilerNoCompiledViewsFound = LoggerMessage.Define(
LogLevel.Debug,
4,
new EventId(4, nameof(ViewCompilerNoCompiledViewsFound)),
"Initializing Razor view compiler with no compiled views.");

_viewCompilerLocatedCompiledViewForPath = LoggerMessage.Define<string>(
LogLevel.Trace,
5,
"Located compiled view for view at path '{Path}'.");

_viewCompilerLocatedCompiledViewForPath = LoggerMessage.Define<string>(
LogLevel.Trace,
5,
new EventId(5, nameof(ViewCompilerLocatedCompiledViewForPath)),
"Located compiled view for view at path '{Path}'.");

_viewCompilerRecompilingCompiledView = LoggerMessage.Define<string>(
LogLevel.Trace,
6,
new EventId(6, "ViewCompilerRecompilingCompiledView"),
"Invalidating compiled view for view at path '{Path}'.");

_viewCompilerCouldNotFindFileToCompileForPath = LoggerMessage.Define<string>(
LogLevel.Trace,
7,
new EventId(7, nameof(ViewCompilerCouldNotFindFileAtPath)),
"Could not find a file for view at path '{Path}'.");

_viewCompilerFoundFileToCompileForPath = LoggerMessage.Define<string>(
LogLevel.Trace,
8,
new EventId(8, nameof(ViewCompilerFoundFileToCompile)),
"Found file at path '{Path}'.");

_viewCompilerInvalidatingCompiledFile = LoggerMessage.Define<string>(
LogLevel.Trace,
9,
new EventId(9, nameof(ViewCompilerInvalidingCompiledFile)),
"Invalidating compiled view at path '{Path}' with a file since the checksum did not match.");

_viewLookupCacheMiss = LoggerMessage.Define<string, string>(
LogLevel.Debug,
1,
new EventId(1, nameof(ViewLookupCacheMiss)),
"View lookup cache miss for view '{ViewName}' in controller '{ControllerName}'.");

_viewLookupCacheHit = LoggerMessage.Define<string, string>(
LogLevel.Debug,
2,
new EventId(2, nameof(ViewLookupCacheHit)),
"View lookup cache hit for view '{ViewName}' in controller '{ControllerName}'.");

_precompiledViewFound = LoggerMessage.Define<string>(
LogLevel.Debug,
3,
new EventId(3, nameof(PrecompiledViewFound)),
"Using precompiled view for '{RelativePath}'.");

_generatedCodeToAssemblyCompilationStart = LoggerMessage.Define<string>(
LogLevel.Debug,
1,
new EventId(1, nameof(GeneratedCodeToAssemblyCompilationStart)),
"Compilation of the generated code for the Razor file at '{FilePath}' started.");

_generatedCodeToAssemblyCompilationEnd = LoggerMessage.Define<string, double>(
LogLevel.Debug,
2,
new EventId(2, nameof(GeneratedCodeToAssemblyCompilationEnd)),
"Compilation of the generated code for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms.");

_tagHelperComponentInitialized = LoggerMessage.Define<string>(
LogLevel.Debug,
2,
new EventId(2, nameof(TagHelperComponentInitialized)),
"Tag helper component '{ComponentName}' initialized.");

_tagHelperComponentProcessed = LoggerMessage.Define<string>(
LogLevel.Debug,
3,
new EventId(3, nameof(TagHelperComponentProcessed)),
"Tag helper component '{ComponentName}' processed.");
}

Expand Down
20 changes: 10 additions & 10 deletions src/Microsoft.AspNetCore.Mvc.RazorPages/PageLoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,52 +30,52 @@ static PageLoggerExtensions()

_handlerMethodExecuting = LoggerMessage.Define<string, string[], ModelValidationState>(
LogLevel.Information,
101,
new EventId(101, nameof(ExecutingHandlerMethod)),
"Executing handler method {HandlerName} with arguments ({Arguments}) - ModelState is {ValidationState}");

_handlerMethodExecuted = LoggerMessage.Define<string, string>(
LogLevel.Information,
102,
new EventId(102, nameof(ExecutedHandlerMethod)),
"Executed handler method {HandlerName}, returned result {ActionResult}.");

_implicitHandlerMethodExecuting = LoggerMessage.Define<ModelValidationState>(
LogLevel.Information,
103,
new EventId(103, nameof(ExecutingImplicitHandlerMethod)),
"Executing an implicit handler method - ModelState is {ValidationState}");

_implicitHandlerMethodExecuted = LoggerMessage.Define<string>(
LogLevel.Information,
104,
new EventId(104, nameof(ExecutedImplicitHandlerMethod)),
"Executed an implicit handler method, returned result {ActionResult}.");

_pageFilterShortCircuit = LoggerMessage.Define<object>(
LogLevel.Debug,
3,
new EventId(3, nameof(PageFilterShortCircuited)),
"Request was short circuited at page filter '{PageFilter}'.");

_malformedPageDirective = LoggerMessage.Define<string, string[]>(
LogLevel.Warning,
104,
new EventId(104, "MalformedPageDirective"),
"The page directive at '{FilePath}' is malformed. Please fix the following issues: {Diagnostics}");

_notMostEffectiveFilter = LoggerMessage.Define<Type>(
LogLevel.Debug,
1,
new EventId(1, nameof(NotMostEffectiveFilter)),
"Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}.");

_beforeExecutingMethodOnFilter = LoggerMessage.Define<string, string, string>(
LogLevel.Trace,
1,
new EventId(1, nameof(BeforeExecutingMethodOnFilter)),
"{FilterType}: Before executing {Method} on filter {Filter}.");

_afterExecutingMethodOnFilter = LoggerMessage.Define<string, string, string>(
LogLevel.Trace,
2,
new EventId(2, nameof(AfterExecutingMethodOnFilter)),
"{FilterType}: After executing {Method} on filter {Filter}.");

_unsupportedAreaPath = LoggerMessage.Define<string>(
LogLevel.Warning,
1,
new EventId(1, nameof(UnsupportedAreaPath)),
"The page at '{FilePath}' is located under the area root directory '/Areas/' but does not follow the path format '/Areas/AreaName/Pages/Directory/FileName.cshtml");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static MvcTagHelperLoggerExtensions()
{
_distributedFormatterDeserializedFailed = LoggerMessage.Define<string>(
LogLevel.Error,
1,
new EventId(1, nameof(DistributedFormatterDeserializationException)),
"Couldn't deserialize cached value for key {Key}.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,83 +42,83 @@ static MvcViewFeaturesLoggerExtensions()
{
_viewComponentExecuting = LoggerMessage.Define<string, string[]>(
LogLevel.Debug,
1,
new EventId(1, nameof(ViewComponentExecuting)),
"Executing view component {ViewComponentName} with arguments ({Arguments}).");

_viewComponentExecuted = LoggerMessage.Define<string, double, string>(
LogLevel.Debug,
2,
new EventId(2, nameof(ViewComponentExecuted)),
"Executed view component {ViewComponentName} in {ElapsedMilliseconds}ms and returned " +
"{ViewComponentResult}");

_partialViewResultExecuting = LoggerMessage.Define<string>(
LogLevel.Information,
1,
new EventId(1, nameof(PartialViewResultExecuting)),
"Executing PartialViewResult, running view {PartialViewName}.");

_partialViewFound = LoggerMessage.Define<string, double>(
LogLevel.Debug,
2,
new EventId(2, nameof(PartialViewFound)),
"The partial view path '{PartialViewFilePath}' was found in {ElapsedMilliseconds}ms.");

_partialViewNotFound = LoggerMessage.Define<string, IEnumerable<string>>(
LogLevel.Error,
3,
new EventId(3, nameof(PartialViewNotFound)),
"The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}");

_partialViewResultExecuted = LoggerMessage.Define<string, double>(
LogLevel.Information,
4,
new EventId(4, nameof(PartialViewResultExecuted)),
"Executed PartialViewResult - view {PartialViewName} executed in {ElapsedMilliseconds}ms.");

_antiforgeryTokenInvalid = LoggerMessage.Define<string>(
LogLevel.Information,
1,
new EventId(1, nameof(AntiforgeryTokenInvalid)),
"Antiforgery token validation failed. {Message}");

_viewComponentResultExecuting = LoggerMessage.Define<string>(
LogLevel.Information,
1,
new EventId(1, nameof(ViewComponentResultExecuting)),
"Executing ViewComponentResult, running {ViewComponentName}.");

_viewResultExecuting = LoggerMessage.Define<string>(
LogLevel.Information,
1,
new EventId(1, nameof(ViewResultExecuting)),
"Executing ViewResult, running view {ViewName}.");

_viewFound = LoggerMessage.Define<string, double>(
LogLevel.Debug,
2,
new EventId(2, nameof(ViewFound)),
"The view path '{ViewFilePath}' was found in {ElapsedMilliseconds}ms.");

_viewNotFound = LoggerMessage.Define<string, IEnumerable<string>>(
LogLevel.Error,
3,
new EventId(3, nameof(ViewNotFound)),
"The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}");

_viewResultExecuted = LoggerMessage.Define<string, double>(
LogLevel.Information,
4,
new EventId(4, nameof(ViewResultExecuted)),
"Executed ViewResult - view {ViewName} executed in {ElapsedMilliseconds}ms.");

_tempDataCookieNotFound = LoggerMessage.Define<string>(
LogLevel.Debug,
1,
new EventId(1, nameof(TempDataCookieNotFound)),
"The temp data cookie {CookieName} was not found.");

_tempDataCookieLoadSuccess = LoggerMessage.Define<string>(
LogLevel.Debug,
2,
new EventId(2, nameof(TempDataCookieLoadSuccess)),
"The temp data cookie {CookieName} was used to successfully load temp data.");

_tempDataCookieLoadFailure = LoggerMessage.Define<string>(
LogLevel.Warning,
3,
new EventId(3, nameof(TempDataCookieLoadFailure)),
"The temp data cookie {CookieName} could not be loaded.");

_notMostEffectiveFilter = LoggerMessage.Define<Type>(
LogLevel.Trace,
1,
new EventId(1, nameof(NotMostEffectiveFilter)),
"Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}.");
}

Expand Down