Skip to content
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
15 changes: 15 additions & 0 deletions Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Locali
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Localization.Tests", "src\Localization\Localization\test\Microsoft.Extensions.Localization.Tests\Microsoft.Extensions.Localization.Tests.csproj", "{F2F6B6FD-C6AC-4536-81ED-4ED52EE2531B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Extensions.Logging.CodeGenerator", "src\Logging\Logging.CodeGenerator\Microsoft.Extensions.Logging.CodeGenerator.csproj", "{5FD1CA5C-9446-4091-8326-D315B1F64BD2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1913,6 +1915,18 @@ Global
{F2F6B6FD-C6AC-4536-81ED-4ED52EE2531B}.Release|x64.Build.0 = Release|Any CPU
{F2F6B6FD-C6AC-4536-81ED-4ED52EE2531B}.Release|x86.ActiveCfg = Release|Any CPU
{F2F6B6FD-C6AC-4536-81ED-4ED52EE2531B}.Release|x86.Build.0 = Release|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Debug|x64.ActiveCfg = Debug|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Debug|x64.Build.0 = Debug|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Debug|x86.ActiveCfg = Debug|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Debug|x86.Build.0 = Debug|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Release|Any CPU.Build.0 = Release|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Release|x64.ActiveCfg = Release|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Release|x64.Build.0 = Release|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Release|x86.ActiveCfg = Release|Any CPU
{5FD1CA5C-9446-4091-8326-D315B1F64BD2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2057,6 +2071,7 @@ Global
{60313ECC-7C20-4509-B41B-C0F69F5162E7} = {6868A014-43FD-4047-B536-30D5D159D9D4}
{8005D6EB-29C9-4A3F-8D8D-5DE255998ECA} = {2FAC6FF0-1FB6-41C6-9A36-FFC2E1727783}
{F2F6B6FD-C6AC-4536-81ED-4ED52EE2531B} = {2FAC6FF0-1FB6-41C6-9A36-FFC2E1727783}
{5FD1CA5C-9446-4091-8326-D315B1F64BD2} = {36DFDB12-6055-43D9-8027-B052667AD34F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {814BFC88-0867-451F-AC8F-20FE107809B4}
Expand Down
1 change: 1 addition & 0 deletions eng/ProjectReferences.props
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<ProjectReferenceProvider Include="Microsoft.Extensions.Localization" ProjectPath="$(RepoRoot)src\Localization\Localization\src\Microsoft.Extensions.Localization.csproj" RefProjectPath="$(RepoRoot)src\Localization\Localization\ref\Microsoft.Extensions.Localization.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.Logging.Abstractions" ProjectPath="$(RepoRoot)src\Logging\Logging.Abstractions\src\Microsoft.Extensions.Logging.Abstractions.csproj" RefProjectPath="$(RepoRoot)src\Logging\Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.Logging.AzureAppServices" ProjectPath="$(RepoRoot)src\Logging\Logging.AzureAppServices\src\Microsoft.Extensions.Logging.AzureAppServices.csproj" RefProjectPath="$(RepoRoot)src\Logging\Logging.AzureAppServices\ref\Microsoft.Extensions.Logging.AzureAppServices.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.Logging.CodeGenerator" ProjectPath="$(RepoRoot)src\Logging\Logging.CodeGenerator\Microsoft.Extensions.Logging.CodeGenerator.csproj" RefProjectPath="$(RepoRoot)src\Logging\ref\Microsoft.Extensions.Logging.CodeGenerator.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.Logging.Configuration" ProjectPath="$(RepoRoot)src\Logging\Logging.Configuration\src\Microsoft.Extensions.Logging.Configuration.csproj" RefProjectPath="$(RepoRoot)src\Logging\Logging.Configuration\ref\Microsoft.Extensions.Logging.Configuration.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.Logging.Console" ProjectPath="$(RepoRoot)src\Logging\Logging.Console\src\Microsoft.Extensions.Logging.Console.csproj" RefProjectPath="$(RepoRoot)src\Logging\Logging.Console\ref\Microsoft.Extensions.Logging.Console.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.Logging.Debug" ProjectPath="$(RepoRoot)src\Logging\Logging.Debug\src\Microsoft.Extensions.Logging.Debug.csproj" RefProjectPath="$(RepoRoot)src\Logging\Logging.Debug\ref\Microsoft.Extensions.Logging.Debug.csproj" />
Expand Down
30 changes: 15 additions & 15 deletions src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,85 +181,85 @@ internal static class EventIds

private static class Log
{
private static readonly Action<ILogger, Exception> _healthCheckProcessingBegin = LoggerMessage.Define(
private static readonly LogMessage _healthCheckProcessingBegin = (
LogLevel.Debug,
EventIds.HealthCheckProcessingBegin,
"Running health checks");

private static readonly Action<ILogger, double, HealthStatus, Exception> _healthCheckProcessingEnd = LoggerMessage.Define<double, HealthStatus>(
private static readonly LogMessage<double, HealthStatus> _healthCheckProcessingEnd = (
LogLevel.Debug,
EventIds.HealthCheckProcessingEnd,
"Health check processing completed after {ElapsedMilliseconds}ms with combined status {HealthStatus}");

private static readonly Action<ILogger, string, Exception> _healthCheckBegin = LoggerMessage.Define<string>(
private static readonly LogMessage<string> _healthCheckBegin = (
LogLevel.Debug,
EventIds.HealthCheckBegin,
"Running health check {HealthCheckName}");

// These are separate so they can have different log levels
private static readonly string HealthCheckEndText = "Health check {HealthCheckName} completed after {ElapsedMilliseconds}ms with status {HealthStatus} and '{HealthCheckDescription}'";

private static readonly Action<ILogger, string, double, HealthStatus, string, Exception> _healthCheckEndHealthy = LoggerMessage.Define<string, double, HealthStatus, string>(
private static readonly LogMessage<string, double, HealthStatus, string> _healthCheckEndHealthy = (
LogLevel.Debug,
EventIds.HealthCheckEnd,
HealthCheckEndText);

private static readonly Action<ILogger, string, double, HealthStatus, string, Exception> _healthCheckEndDegraded = LoggerMessage.Define<string, double, HealthStatus, string>(
private static readonly LogMessage<string, double, HealthStatus, string> _healthCheckEndDegraded = (
LogLevel.Warning,
EventIds.HealthCheckEnd,
HealthCheckEndText);

private static readonly Action<ILogger, string, double, HealthStatus, string, Exception> _healthCheckEndUnhealthy = LoggerMessage.Define<string, double, HealthStatus, string>(
private static readonly LogMessage<string, double, HealthStatus, string> _healthCheckEndUnhealthy = (
LogLevel.Error,
EventIds.HealthCheckEnd,
HealthCheckEndText);

private static readonly Action<ILogger, string, double, HealthStatus, string, Exception> _healthCheckEndFailed = LoggerMessage.Define<string, double, HealthStatus, string>(
private static readonly LogMessage<string, double, HealthStatus, string> _healthCheckEndFailed = (
LogLevel.Error,
EventIds.HealthCheckEnd,
HealthCheckEndText);

private static readonly Action<ILogger, string, double, Exception> _healthCheckError = LoggerMessage.Define<string, double>(
private static readonly LogMessage<string, double> _healthCheckError = (
LogLevel.Error,
EventIds.HealthCheckError,
"Health check {HealthCheckName} threw an unhandled exception after {ElapsedMilliseconds}ms");

public static void HealthCheckProcessingBegin(ILogger logger)
{
_healthCheckProcessingBegin(logger, null);
_healthCheckProcessingBegin.Log(logger);
}

public static void HealthCheckProcessingEnd(ILogger logger, HealthStatus status, TimeSpan duration)
{
_healthCheckProcessingEnd(logger, duration.TotalMilliseconds, status, null);
_healthCheckProcessingEnd.Log(logger, duration.TotalMilliseconds, status);
}

public static void HealthCheckBegin(ILogger logger, HealthCheckRegistration registration)
{
_healthCheckBegin(logger, registration.Name, null);
_healthCheckBegin.Log(logger, registration.Name);
}

public static void HealthCheckEnd(ILogger logger, HealthCheckRegistration registration, HealthReportEntry entry, TimeSpan duration)
{
switch (entry.Status)
{
case HealthStatus.Healthy:
_healthCheckEndHealthy(logger, registration.Name, duration.TotalMilliseconds, entry.Status, entry.Description, null);
_healthCheckEndHealthy.Log(logger, registration.Name, duration.TotalMilliseconds, entry.Status, entry.Description);
break;

case HealthStatus.Degraded:
_healthCheckEndDegraded(logger, registration.Name, duration.TotalMilliseconds, entry.Status, entry.Description, null);
_healthCheckEndDegraded.Log(logger, registration.Name, duration.TotalMilliseconds, entry.Status, entry.Description);
break;

case HealthStatus.Unhealthy:
_healthCheckEndUnhealthy(logger, registration.Name, duration.TotalMilliseconds, entry.Status, entry.Description, null);
_healthCheckEndUnhealthy.Log(logger, registration.Name, duration.TotalMilliseconds, entry.Status, entry.Description);
break;
}
}

public static void HealthCheckError(ILogger logger, HealthCheckRegistration registration, Exception exception, TimeSpan duration)
{
_healthCheckError(logger, registration.Name, duration.TotalMilliseconds, exception);
_healthCheckError.Log(logger, exception, registration.Name, duration.TotalMilliseconds);
}

public static void HealthCheckData(ILogger logger, HealthCheckRegistration registration, HealthReportEntry entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,64 +198,64 @@ internal static class EventIds

private static class Logger
{
private static readonly Action<ILogger, Exception> _healthCheckPublisherProcessingBegin = LoggerMessage.Define(
private static readonly LogMessage _healthCheckPublisherProcessingBegin = (
LogLevel.Debug,
EventIds.HealthCheckPublisherProcessingBegin,
"Running health check publishers");

private static readonly Action<ILogger, double, Exception> _healthCheckPublisherProcessingEnd = LoggerMessage.Define<double>(
private static readonly LogMessage<double> _healthCheckPublisherProcessingEnd = (
LogLevel.Debug,
EventIds.HealthCheckPublisherProcessingEnd,
"Health check publisher processing completed after {ElapsedMilliseconds}ms");

private static readonly Action<ILogger, IHealthCheckPublisher, Exception> _healthCheckPublisherBegin = LoggerMessage.Define<IHealthCheckPublisher>(
private static readonly LogMessage<IHealthCheckPublisher> _healthCheckPublisherBegin = (
LogLevel.Debug,
EventIds.HealthCheckPublisherBegin,
"Running health check publisher '{HealthCheckPublisher}'");

private static readonly Action<ILogger, IHealthCheckPublisher, double, Exception> _healthCheckPublisherEnd = LoggerMessage.Define<IHealthCheckPublisher, double>(
private static readonly LogMessage<IHealthCheckPublisher, double> _healthCheckPublisherEnd = (
LogLevel.Debug,
EventIds.HealthCheckPublisherEnd,
"Health check '{HealthCheckPublisher}' completed after {ElapsedMilliseconds}ms");

private static readonly Action<ILogger, IHealthCheckPublisher, double, Exception> _healthCheckPublisherError = LoggerMessage.Define<IHealthCheckPublisher, double>(
private static readonly LogMessage<IHealthCheckPublisher, double> _healthCheckPublisherError = (
LogLevel.Error,
EventIds.HealthCheckPublisherError,
"Health check {HealthCheckPublisher} threw an unhandled exception after {ElapsedMilliseconds}ms");

private static readonly Action<ILogger, IHealthCheckPublisher, double, Exception> _healthCheckPublisherTimeout = LoggerMessage.Define<IHealthCheckPublisher, double>(
private static readonly LogMessage<IHealthCheckPublisher, double> _healthCheckPublisherTimeout = (
LogLevel.Error,
EventIds.HealthCheckPublisherTimeout,
"Health check {HealthCheckPublisher} was canceled after {ElapsedMilliseconds}ms");

public static void HealthCheckPublisherProcessingBegin(ILogger logger)
{
_healthCheckPublisherProcessingBegin(logger, null);
_healthCheckPublisherProcessingBegin.Log(logger);
}

public static void HealthCheckPublisherProcessingEnd(ILogger logger, TimeSpan duration, Exception exception = null)
{
_healthCheckPublisherProcessingEnd(logger, duration.TotalMilliseconds, exception);
_healthCheckPublisherProcessingEnd.Log(logger, exception, duration.TotalMilliseconds);
}

public static void HealthCheckPublisherBegin(ILogger logger, IHealthCheckPublisher publisher)
{
_healthCheckPublisherBegin(logger, publisher, null);
_healthCheckPublisherBegin.Log(logger, publisher);
}

public static void HealthCheckPublisherEnd(ILogger logger, IHealthCheckPublisher publisher, TimeSpan duration)
{
_healthCheckPublisherEnd(logger, publisher, duration.TotalMilliseconds, null);
_healthCheckPublisherEnd.Log(logger, publisher, duration.TotalMilliseconds);
}

public static void HealthCheckPublisherError(ILogger logger, IHealthCheckPublisher publisher, TimeSpan duration, Exception exception)
{
_healthCheckPublisherError(logger, publisher, duration.TotalMilliseconds, exception);
_healthCheckPublisherError.Log(logger, exception, publisher, duration.TotalMilliseconds);
}

public static void HealthCheckPublisherTimeout(ILogger logger, IHealthCheckPublisher publisher, TimeSpan duration)
{
_healthCheckPublisherTimeout(logger, publisher, duration.TotalMilliseconds, null);
_healthCheckPublisherTimeout.Log(logger, publisher, duration.TotalMilliseconds);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/HttpClientFactory/Http/src/DefaultHttpClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,45 +340,45 @@ public static class EventIds
public static readonly EventId HandlerExpired = new EventId(103, "HandlerExpired");
}

private static readonly Action<ILogger, int, Exception> _cleanupCycleStart = LoggerMessage.Define<int>(
private static readonly LogMessage<int> _cleanupCycleStart = (
LogLevel.Debug,
EventIds.CleanupCycleStart,
"Starting HttpMessageHandler cleanup cycle with {InitialCount} items");

private static readonly Action<ILogger, double, int, int, Exception> _cleanupCycleEnd = LoggerMessage.Define<double, int, int>(
private static readonly LogMessage<double, int, int> _cleanupCycleEnd = (
LogLevel.Debug,
EventIds.CleanupCycleEnd,
"Ending HttpMessageHandler cleanup cycle after {ElapsedMilliseconds}ms - processed: {DisposedCount} items - remaining: {RemainingItems} items");

private static readonly Action<ILogger, string, Exception> _cleanupItemFailed = LoggerMessage.Define<string>(
private static readonly LogMessage<string> _cleanupItemFailed = (
LogLevel.Error,
EventIds.CleanupItemFailed,
"HttpMessageHandler.Dispose() threw and unhandled exception for client: '{ClientName}'");

private static readonly Action<ILogger, double, string, Exception> _handlerExpired = LoggerMessage.Define<double, string>(
private static readonly LogMessage<double, string> _handlerExpired = (
LogLevel.Debug,
EventIds.HandlerExpired,
"HttpMessageHandler expired after {HandlerLifetime}ms for client '{ClientName}'");


public static void CleanupCycleStart(ILogger logger, int initialCount)
{
_cleanupCycleStart(logger, initialCount, null);
_cleanupCycleStart.Log(logger, initialCount);
}

public static void CleanupCycleEnd(ILogger logger, TimeSpan duration, int disposedCount, int finalCount)
{
_cleanupCycleEnd(logger, duration.TotalMilliseconds, disposedCount, finalCount, null);
_cleanupCycleEnd.Log(logger, duration.TotalMilliseconds, disposedCount, finalCount);
}

public static void CleanupItemFailed(ILogger logger, string clientName, Exception exception)
{
_cleanupItemFailed(logger, clientName, exception);
_cleanupItemFailed.Log(logger, exception, clientName);
}

public static void HandlerExpired(ILogger logger, string clientName, TimeSpan lifetime)
{
_handlerExpired(logger, lifetime.TotalMilliseconds, clientName, null);
_handlerExpired.Log(logger, lifetime.TotalMilliseconds, clientName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ public static class EventIds
public static readonly EventId ResponseHeader = new EventId(103, "ResponseHeader");
}

private static readonly Action<ILogger, HttpMethod, Uri, Exception> _requestStart = LoggerMessage.Define<HttpMethod, Uri>(
private static readonly LogMessage<HttpMethod, Uri> _requestStart = (
LogLevel.Information,
EventIds.RequestStart,
"Sending HTTP request {HttpMethod} {Uri}");

private static readonly Action<ILogger, double, HttpStatusCode, Exception> _requestEnd = LoggerMessage.Define<double, HttpStatusCode>(
private static readonly LogMessage<double, HttpStatusCode> _requestEnd = (
LogLevel.Information,
EventIds.RequestEnd,
"Received HTTP response after {ElapsedMilliseconds}ms - {StatusCode}");

public static void RequestStart(ILogger logger, HttpRequestMessage request)
{
_requestStart(logger, request.Method, request.RequestUri, null);
_requestStart.Log(logger, request.Method, request.RequestUri);

if (logger.IsEnabled(LogLevel.Trace))
{
Expand All @@ -86,7 +86,7 @@ public static void RequestStart(ILogger logger, HttpRequestMessage request)

public static void RequestEnd(ILogger logger, HttpResponseMessage response, TimeSpan duration)
{
_requestEnd(logger, duration.TotalMilliseconds, response.StatusCode, null);
_requestEnd.Log(logger, duration.TotalMilliseconds, response.StatusCode);

if (logger.IsEnabled(LogLevel.Trace))
{
Expand Down
Loading