Skip to content

Commit 36de4d7

Browse files
Remove log partials with one message
Move the log partial classes that only contained one logger message directly into the classes that use them.
1 parent b239111 commit 36de4d7

File tree

4 files changed

+12
-49
lines changed

4 files changed

+12
-49
lines changed

src/Servers/HttpSys/src/NativeInterop/RequestQueue.Log.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Servers/HttpSys/src/NativeInterop/RequestQueue.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
namespace Microsoft.AspNetCore.Server.HttpSys
1212
{
13-
internal partial class RequestQueue
13+
internal class RequestQueue
1414
{
1515
private static readonly int BindingInfoSize =
1616
Marshal.SizeOf<HttpApiTypes.HTTP_BINDING_INFO>();
1717

18+
private static readonly Action<ILogger, string?, Exception?> _attachedToQueue =
19+
LoggerMessage.Define<string?>(LogLevel.Information, LoggerEventIds.AttachedToQueue, "Attached to an existing request queue '{RequestQueueName}', some options do not apply.");
20+
1821
private readonly RequestQueueMode _mode;
1922
private readonly ILogger _logger;
2023
private bool _disposed;
@@ -105,7 +108,7 @@ private RequestQueue(UrlGroup urlGroup, string? requestQueueName, RequestQueueMo
105108

106109
if (!Created)
107110
{
108-
Log.AttachedToQueue(_logger, requestQueueName);
111+
_attachedToQueue(_logger, requestQueueName, null);
109112
}
110113
}
111114

src/Servers/HttpSys/src/RequestProcessing/Request.Log.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Servers/HttpSys/src/RequestProcessing/Request.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
using System.Threading;
1515
using System.Threading.Tasks;
1616
using Microsoft.AspNetCore.HttpSys.Internal;
17+
using Microsoft.Extensions.Logging;
1718

1819
namespace Microsoft.AspNetCore.Server.HttpSys
1920
{
20-
internal sealed partial class Request
21+
internal sealed class Request
2122
{
23+
private static readonly Action<ILogger, Exception?> _errorInReadingCertificate =
24+
LoggerMessage.Define(LogLevel.Debug, LoggerEventIds.ErrorInReadingCertificate, "An error occurred reading the client certificate.");
25+
2226
private X509Certificate2? _clientCert;
2327
// TODO: https://github.com/aspnet/HttpSysServer/issues/231
2428
// private byte[] _providedTokenBindingId;
@@ -336,11 +340,11 @@ public X509Certificate2? ClientCertificate
336340
}
337341
catch (CryptographicException ce)
338342
{
339-
Log.ErrorInReadingCertificate(RequestContext.Logger, ce);
343+
_errorInReadingCertificate(RequestContext.Logger, ce);
340344
}
341345
catch (SecurityException se)
342346
{
343-
Log.ErrorInReadingCertificate(RequestContext.Logger, se);
347+
_errorInReadingCertificate(RequestContext.Logger, se);
344348
}
345349
}
346350

0 commit comments

Comments
 (0)