add names to EventIds used by logger extensions (#927)

This commit is contained in:
Andrew Stanton-Nurse 2017-09-21 17:36:50 -07:00 committed by GitHub
parent 9ecb6d1d58
commit 786980bc3f
6 changed files with 130 additions and 130 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -11,97 +11,97 @@ namespace Microsoft.AspNetCore.SignalR.Client.Internal
{
// Category: HubConnection
private static readonly Action<ILogger, string, string, int, Exception> _preparingNonBlockingInvocation =
LoggerMessage.Define<string, string, int>(LogLevel.Trace, 0, "Preparing non-blocking invocation '{invocationId}' of '{target}', with {argumentCount} argument(s).");
LoggerMessage.Define<string, string, int>(LogLevel.Trace, new EventId(0, nameof(PreparingNonBlockingInvocation)), "Preparing non-blocking invocation '{invocationId}' of '{target}', with {argumentCount} argument(s).");
private static readonly Action<ILogger, string, string, string, int, Exception> _preparingBlockingInvocation =
LoggerMessage.Define<string, string, string, int>(LogLevel.Trace, 1, "Preparing blocking invocation '{invocationId}' of '{target}', with return type '{returnType}' and {argumentCount} argument(s).");
LoggerMessage.Define<string, string, string, int>(LogLevel.Trace, new EventId(1, nameof(PreparingBlockingInvocation)), "Preparing blocking invocation '{invocationId}' of '{target}', with return type '{returnType}' and {argumentCount} argument(s).");
private static readonly Action<ILogger, string, Exception> _registerInvocation =
LoggerMessage.Define<string>(LogLevel.Debug, 2, "Registering Invocation ID '{invocationId}' for tracking.");
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(2, nameof(RegisterInvocation)), "Registering Invocation ID '{invocationId}' for tracking.");
private static readonly Action<ILogger, string, string, string, string, Exception> _issueInvocation =
LoggerMessage.Define<string, string, string, string>(LogLevel.Trace, 3, "Issuing Invocation '{invocationId}': {returnType} {methodName}({args}).");
LoggerMessage.Define<string, string, string, string>(LogLevel.Trace, new EventId(3, nameof(IssueInvocation)), "Issuing Invocation '{invocationId}': {returnType} {methodName}({args}).");
private static readonly Action<ILogger, string, Exception> _sendInvocation =
LoggerMessage.Define<string>(LogLevel.Debug, 4, "Sending Invocation '{invocationId}'.");
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(4, nameof(SendInvocation)), "Sending Invocation '{invocationId}'.");
private static readonly Action<ILogger, string, Exception> _sendInvocationCompleted =
LoggerMessage.Define<string>(LogLevel.Debug, 5, "Sending Invocation '{invocationId}' completed.");
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(5, nameof(SendInvocationCompleted)), "Sending Invocation '{invocationId}' completed.");
private static readonly Action<ILogger, string, Exception> _sendInvocationFailed =
LoggerMessage.Define<string>(LogLevel.Error, 6, "Sending Invocation '{invocationId}' failed.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(6, nameof(SendInvocationFailed)), "Sending Invocation '{invocationId}' failed.");
private static readonly Action<ILogger, string, string, string, Exception> _receivedInvocation =
LoggerMessage.Define<string, string, string>(LogLevel.Trace, 7, "Received Invocation '{invocationId}': {methodName}({args}).");
LoggerMessage.Define<string, string, string>(LogLevel.Trace, new EventId(7, nameof(ReceivedInvocation)), "Received Invocation '{invocationId}': {methodName}({args}).");
private static readonly Action<ILogger, string, Exception> _dropCompletionMessage =
LoggerMessage.Define<string>(LogLevel.Warning, 8, "Dropped unsolicited Completion message for invocation '{invocationId}'.");
LoggerMessage.Define<string>(LogLevel.Warning, new EventId(8, nameof(DropCompletionMessage)), "Dropped unsolicited Completion message for invocation '{invocationId}'.");
private static readonly Action<ILogger, string, Exception> _dropStreamMessage =
LoggerMessage.Define<string>(LogLevel.Warning, 9, "Dropped unsolicited StreamItem message for invocation '{invocationId}'.");
LoggerMessage.Define<string>(LogLevel.Warning, new EventId(9, nameof(DropStreamMessage)), "Dropped unsolicited StreamItem message for invocation '{invocationId}'.");
private static readonly Action<ILogger, Exception> _shutdownConnection =
LoggerMessage.Define(LogLevel.Trace, 10, "Shutting down connection.");
LoggerMessage.Define(LogLevel.Trace, new EventId(10, nameof(ShutdownConnection)), "Shutting down connection.");
private static readonly Action<ILogger, Exception> _shutdownWithError =
LoggerMessage.Define(LogLevel.Error, 11, "Connection is shutting down due to an error.");
LoggerMessage.Define(LogLevel.Error, new EventId(11, nameof(ShutdownWithError)), "Connection is shutting down due to an error.");
private static readonly Action<ILogger, string, Exception> _removeInvocation =
LoggerMessage.Define<string>(LogLevel.Trace, 12, "Removing pending invocation {invocationId}.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(12, nameof(RemoveInvocation)), "Removing pending invocation {invocationId}.");
private static readonly Action<ILogger, string, Exception> _missingHandler =
LoggerMessage.Define<string>(LogLevel.Warning, 13, "Failed to find handler for '{target}' method.");
LoggerMessage.Define<string>(LogLevel.Warning, new EventId(13, nameof(MissingHandler)), "Failed to find handler for '{target}' method.");
private static readonly Action<ILogger, string, Exception> _receivedStreamItem =
LoggerMessage.Define<string>(LogLevel.Trace, 14, "Received StreamItem for Invocation {invocationId}.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(14, nameof(ReceivedStreamItem)), "Received StreamItem for Invocation {invocationId}.");
private static readonly Action<ILogger, string, Exception> _cancelingStreamItem =
LoggerMessage.Define<string>(LogLevel.Trace, 15, "Canceling dispatch of StreamItem message for Invocation {invocationId}. The invocation was canceled.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(15, nameof(CancelingStreamItem)), "Canceling dispatch of StreamItem message for Invocation {invocationId}. The invocation was canceled.");
private static readonly Action<ILogger, string, Exception> _receivedStreamItemAfterClose =
LoggerMessage.Define<string>(LogLevel.Warning, 16, "Invocation {invocationId} received stream item after channel was closed.");
LoggerMessage.Define<string>(LogLevel.Warning, new EventId(16, nameof(ReceivedStreamItemAfterClose)), "Invocation {invocationId} received stream item after channel was closed.");
private static readonly Action<ILogger, string, Exception> _receivedInvocationCompletion =
LoggerMessage.Define<string>(LogLevel.Trace, 17, "Received Completion for Invocation {invocationId}.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(17, nameof(ReceivedInvocationCompletion)), "Received Completion for Invocation {invocationId}.");
private static readonly Action<ILogger, string, Exception> _cancelingCompletion =
LoggerMessage.Define<string>(LogLevel.Trace, 18, "Canceling dispatch of Completion message for Invocation {invocationId}. The invocation was canceled.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(18, nameof(CancelingCompletion)), "Canceling dispatch of Completion message for Invocation {invocationId}. The invocation was canceled.");
private static readonly Action<ILogger, string, Exception> _invokeAfterTermination =
LoggerMessage.Define<string>(LogLevel.Error, 19, "Invoke for Invocation '{invocationId}' was called after the connection was terminated.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(19, nameof(InvokeAfterTermination)), "Invoke for Invocation '{invocationId}' was called after the connection was terminated.");
private static readonly Action<ILogger, string, Exception> _invocationAlreadyInUse =
LoggerMessage.Define<string>(LogLevel.Critical, 20, "Invocation ID '{invocationId}' is already in use.");
LoggerMessage.Define<string>(LogLevel.Critical, new EventId(20, nameof(InvocationAlreadyInUse)), "Invocation ID '{invocationId}' is already in use.");
private static readonly Action<ILogger, string, Exception> _receivedUnexpectedResponse =
LoggerMessage.Define<string>(LogLevel.Error, 21, "Unsolicited response received for invocation '{invocationId}'.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(21, nameof(ReceivedUnexpectedResponse)), "Unsolicited response received for invocation '{invocationId}'.");
private static readonly Action<ILogger, string, Exception> _hubProtocol =
LoggerMessage.Define<string>(LogLevel.Information, 22, "Using HubProtocol '{protocol}'.");
LoggerMessage.Define<string>(LogLevel.Information, new EventId(22, nameof(HubProtocol)), "Using HubProtocol '{protocol}'.");
// Category: Streaming and NonStreaming
private static readonly Action<ILogger, string, Exception> _invocationCreated =
LoggerMessage.Define<string>(LogLevel.Trace, 0, "Invocation {invocationId} created.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(0, nameof(InvocationCreated)), "Invocation {invocationId} created.");
private static readonly Action<ILogger, string, Exception> _invocationDisposed =
LoggerMessage.Define<string>(LogLevel.Trace, 1, "Invocation {invocationId} disposed.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(1, nameof(InvocationDisposed)), "Invocation {invocationId} disposed.");
private static readonly Action<ILogger, string, Exception> _invocationCompleted =
LoggerMessage.Define<string>(LogLevel.Trace, 2, "Invocation {invocationId} marked as completed.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(2, nameof(InvocationCompleted)), "Invocation {invocationId} marked as completed.");
private static readonly Action<ILogger, string, Exception> _invocationFailed =
LoggerMessage.Define<string>(LogLevel.Trace, 3, "Invocation {invocationId} marked as failed.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(3, nameof(InvocationFailed)), "Invocation {invocationId} marked as failed.");
// Category: Streaming
private static readonly Action<ILogger, string, Exception> _receivedUnexpectedComplete =
LoggerMessage.Define<string>(LogLevel.Error, 4, "Invocation {invocationId} received a completion result, but was invoked as a streaming invocation.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(4, nameof(ReceivedUnexpectedComplete)), "Invocation {invocationId} received a completion result, but was invoked as a streaming invocation.");
private static readonly Action<ILogger, string, Exception> _errorWritingStreamItem =
LoggerMessage.Define<string>(LogLevel.Error, 5, "Invocation {invocationId} caused an error trying to write a stream item.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(5, nameof(ErrorWritingStreamItem)), "Invocation {invocationId} caused an error trying to write a stream item.");
// Category: NonStreaming
private static readonly Action<ILogger, string, Exception> _streamItemOnNonStreamInvocation =
LoggerMessage.Define<string>(LogLevel.Error, 4, "Invocation {invocationId} received stream item but was invoked as a non-streamed invocation.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(4, nameof(StreamItemOnNonStreamInvocation)), "Invocation {invocationId} received stream item but was invoked as a non-streamed invocation.");
public static void PreparingNonBlockingInvocation(this ILogger logger, string invocationId, string target, int count)
{

View File

@ -11,43 +11,43 @@ namespace Microsoft.AspNetCore.SignalR.Core.Internal
{
// Category: HubEndPoint<THub>
private static readonly Action<ILogger, string, Exception> _usingHubProtocol =
LoggerMessage.Define<string>(LogLevel.Information, 0, "Using HubProtocol '{protocol}'.");
LoggerMessage.Define<string>(LogLevel.Information, new EventId(0, nameof(UsingHubProtocol)), "Using HubProtocol '{protocol}'.");
private static readonly Action<ILogger, Exception> _negotiateCanceled =
LoggerMessage.Define(LogLevel.Debug, 1, "Negotiate was canceled.");
LoggerMessage.Define(LogLevel.Debug, new EventId(1, nameof(NegotiateCanceled)), "Negotiate was canceled.");
private static readonly Action<ILogger, Exception> _errorProcessingRequest =
LoggerMessage.Define(LogLevel.Error, 2, "Error when processing requests.");
LoggerMessage.Define(LogLevel.Error, new EventId(2, nameof(ErrorProcessingRequest)), "Error when processing requests.");
private static readonly Action<ILogger, string, Exception> _errorInvokingHubMethod =
LoggerMessage.Define<string>(LogLevel.Error, 3, "Error when invoking '{hubMethod}' on hub.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(3, nameof(ErrorInvokingHubMethod)), "Error when invoking '{hubMethod}' on hub.");
private static readonly Action<ILogger, InvocationMessage, Exception> _receivedHubInvocation =
LoggerMessage.Define<InvocationMessage>(LogLevel.Debug, 4, "Received hub invocation: {invocationMessage}.");
LoggerMessage.Define<InvocationMessage>(LogLevel.Debug, new EventId(4, nameof(ReceivedHubInvocation)), "Received hub invocation: {invocationMessage}.");
private static readonly Action<ILogger, string, Exception> _unsupportedMessageReceived =
LoggerMessage.Define<string>(LogLevel.Error, 5, "Received unsupported message of type '{messageType}'.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(5, nameof(UnsupportedMessageReceived)), "Received unsupported message of type '{messageType}'.");
private static readonly Action<ILogger, string, Exception> _unknownHubMethod =
LoggerMessage.Define<string>(LogLevel.Error, 6, "Unknown hub method '{hubMethod}'.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(6, nameof(UnknownHubMethod)), "Unknown hub method '{hubMethod}'.");
private static readonly Action<ILogger, Exception> _outboundChannelClosed =
LoggerMessage.Define(LogLevel.Warning, 7, "Outbound channel was closed while trying to write hub message.");
LoggerMessage.Define(LogLevel.Warning, new EventId(7, nameof(OutboundChannelClosed)), "Outbound channel was closed while trying to write hub message.");
private static readonly Action<ILogger, string, Exception> _hubMethodNotAuthorized =
LoggerMessage.Define<string>(LogLevel.Debug, 8, "Failed to invoke '{hubMethod}' because user is unauthorized.");
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(8, nameof(HubMethodNotAuthorized)), "Failed to invoke '{hubMethod}' because user is unauthorized.");
private static readonly Action<ILogger, string, string, Exception> _streamingResult =
LoggerMessage.Define<string, string>(LogLevel.Trace, 9, "{invocationId}: Streaming result of type '{resultType}'.");
LoggerMessage.Define<string, string>(LogLevel.Trace, new EventId(9, nameof(StreamingResult)), "{invocationId}: Streaming result of type '{resultType}'.");
private static readonly Action<ILogger, string, string, Exception> _sendingResult =
LoggerMessage.Define<string, string>(LogLevel.Trace, 10, "{invocationId}: Sending result of type '{resultType}'.");
LoggerMessage.Define<string, string>(LogLevel.Trace, new EventId(10, nameof(SendingResult)), "{invocationId}: Sending result of type '{resultType}'.");
private static readonly Action<ILogger, string, Exception> _failedInvokingHubMethod =
LoggerMessage.Define<string>(LogLevel.Error, 11, "Failed to invoke hub method '{hubMethod}'.");
LoggerMessage.Define<string>(LogLevel.Error, new EventId(11, nameof(FailedInvokingHubMethod)), "Failed to invoke hub method '{hubMethod}'.");
private static readonly Action<ILogger, string, Exception> _hubMethodBound =
LoggerMessage.Define<string>(LogLevel.Trace, 12, "Hub method '{hubMethod}' is bound.");
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(12, nameof(HubMethodBound)), "Hub method '{hubMethod}' is bound.");
public static void UsingHubProtocol(this ILogger logger, string hubProtocol)
{
@ -114,4 +114,4 @@ namespace Microsoft.AspNetCore.SignalR.Core.Internal
_hubMethodBound(logger, hubMethod, null);
}
}
}
}

View File

@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Sockets.Client
}
catch (Exception ex)
{
_logger.ExceptionThrownFromEventHandler(_connectionId, nameof(Connected), ex);
_logger.ExceptionThrownFromHandler(_connectionId, nameof(Connected), ex);
}
}
});
@ -205,7 +205,7 @@ namespace Microsoft.AspNetCore.Sockets.Client
}
catch (Exception ex)
{
_logger.ExceptionThrownFromEventHandler(_connectionId, nameof(Closed), ex);
_logger.ExceptionThrownFromHandler(_connectionId, nameof(Closed), ex);
}
}
});
@ -366,7 +366,7 @@ namespace Microsoft.AspNetCore.Sockets.Client
}
catch (Exception ex)
{
_logger.ExceptionThrownFromEventHandler(_connectionId, nameof(Received), ex);
_logger.ExceptionThrownFromHandler(_connectionId, nameof(Received), ex);
}
}
});

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -11,147 +11,147 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal
{
// Category: Shared with LongPollingTransport, WebSocketsTransport and ServerSentEventsTransport
private static readonly Action<ILogger, DateTime, string, TransferMode, Exception> _startTransport =
LoggerMessage.Define<DateTime, string, TransferMode>(LogLevel.Information, 0, "{time}: Connection Id {connectionId}: Starting transport. Transfer mode: {transferMode}.");
LoggerMessage.Define<DateTime, string, TransferMode>(LogLevel.Information, new EventId(0, nameof(StartTransport)), "{time}: Connection Id {connectionId}: Starting transport. Transfer mode: {transferMode}.");
private static readonly Action<ILogger, DateTime, string, Exception> _transportStopped =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 1, "{time}: Connection Id {connectionId}: Transport stopped.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(1, nameof(TransportStopped)), "{time}: Connection Id {connectionId}: Transport stopped.");
private static readonly Action<ILogger, DateTime, string, Exception> _startReceive =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 2, "{time}: Connection Id {connectionId}: Starting receive loop.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(2, nameof(StartReceive)), "{time}: Connection Id {connectionId}: Starting receive loop.");
private static readonly Action<ILogger, DateTime, string, Exception> _receiveStopped =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 3, "{time}: Connection Id {connectionId}: Receive loop stopped.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(3, nameof(ReceiveStopped)), "{time}: Connection Id {connectionId}: Receive loop stopped.");
private static readonly Action<ILogger, DateTime, string, Exception> _receiveCanceled =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 4, "{time}: Connection Id {connectionId}: Receive loop canceled.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(4, nameof(ReceiveCanceled)), "{time}: Connection Id {connectionId}: Receive loop canceled.");
private static readonly Action<ILogger, DateTime, string, Exception> _transportStopping =
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 5, "{time}: Connection Id {connectionId}: Transport is stopping.");
LoggerMessage.Define<DateTime, string>(LogLevel.Information, new EventId(5, nameof(TransportStopping)), "{time}: Connection Id {connectionId}: Transport is stopping.");
private static readonly Action<ILogger, DateTime, string, Exception> _sendStarted =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 6, "{time}: Connection Id {connectionId}: Starting the send loop.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(6, nameof(SendStarted)), "{time}: Connection Id {connectionId}: Starting the send loop.");
private static readonly Action<ILogger, DateTime, string, Exception> _sendStopped =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 7, "{time}: Connection Id {connectionId}: Send loop stopped.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(7, nameof(SendStopped)), "{time}: Connection Id {connectionId}: Send loop stopped.");
private static readonly Action<ILogger, DateTime, string, Exception> _sendCanceled =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 8, "{time}: Connection Id {connectionId}: Send loop canceled.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(8, nameof(SendCanceled)), "{time}: Connection Id {connectionId}: Send loop canceled.");
// Category: WebSocketsTransport
private static readonly Action<ILogger, DateTime, string, WebSocketCloseStatus?, Exception> _webSocketClosed =
LoggerMessage.Define<DateTime, string, WebSocketCloseStatus?>(LogLevel.Information, 9, "{time}: Connection Id {connectionId}: Websocket closed by the server. Close status {closeStatus}.");
LoggerMessage.Define<DateTime, string, WebSocketCloseStatus?>(LogLevel.Information, new EventId(9, nameof(WebSocketClosed)), "{time}: Connection Id {connectionId}: Websocket closed by the server. Close status {closeStatus}.");
private static readonly Action<ILogger, DateTime, string, WebSocketMessageType, int, bool, Exception> _messageReceived =
LoggerMessage.Define<DateTime, string, WebSocketMessageType, int, bool>(LogLevel.Debug, 10, "{time}: Connection Id {connectionId}: Message received. Type: {messageType}, size: {count}, EndOfMessage: {endOfMessage}.");
LoggerMessage.Define<DateTime, string, WebSocketMessageType, int, bool>(LogLevel.Debug, new EventId(10, nameof(MessageReceived)), "{time}: Connection Id {connectionId}: Message received. Type: {messageType}, size: {count}, EndOfMessage: {endOfMessage}.");
private static readonly Action<ILogger, DateTime, string, int, Exception> _messageToApp =
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, 11, "{time}: Connection Id {connectionId}: Passing message to application. Payload size: {count}.");
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, new EventId(11, nameof(MessageToApp)), "{time}: Connection Id {connectionId}: Passing message to application. Payload size: {count}.");
private static readonly Action<ILogger, DateTime, string, int, Exception> _receivedFromApp =
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, 12, "{time}: Connection Id {connectionId}: Received message from application. Payload size: {count}.");
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, new EventId(12, nameof(ReceivedFromApp)), "{time}: Connection Id {connectionId}: Received message from application. Payload size: {count}.");
private static readonly Action<ILogger, DateTime, string, Exception> _sendMessageCanceled =
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 13, "{time}: Connection Id {connectionId}: Sending a message canceled.");
LoggerMessage.Define<DateTime, string>(LogLevel.Information, new EventId(13, nameof(SendMessageCanceled)), "{time}: Connection Id {connectionId}: Sending a message canceled.");
private static readonly Action<ILogger, DateTime, string, Exception> _errorSendingMessage =
LoggerMessage.Define<DateTime, string>(LogLevel.Error, 14, "{time}: Connection Id {connectionId}: Error while sending a message.");
LoggerMessage.Define<DateTime, string>(LogLevel.Error, new EventId(14, nameof(ErrorSendingMessage)), "{time}: Connection Id {connectionId}: Error while sending a message.");
private static readonly Action<ILogger, DateTime, string, Exception> _closingWebSocket =
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 15, "{time}: Connection Id {connectionId}: Closing WebSocket.");
LoggerMessage.Define<DateTime, string>(LogLevel.Information, new EventId(15, nameof(ClosingWebSocket)), "{time}: Connection Id {connectionId}: Closing WebSocket.");
private static readonly Action<ILogger, DateTime, string, Exception> _closingWebSocketFailed =
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 16, "{time}: Connection Id {connectionId}: Closing webSocket failed.");
LoggerMessage.Define<DateTime, string>(LogLevel.Information, new EventId(16, nameof(ClosingWebSocketFailed)), "{time}: Connection Id {connectionId}: Closing webSocket failed.");
private static readonly Action<ILogger, DateTime, string, Exception> _cancelMessage =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 17, "{time}: Connection Id {connectionId}: Canceled passing message to application.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(17, nameof(CancelMessage)), "{time}: Connection Id {connectionId}: Canceled passing message to application.");
// Category: ServerSentEventsTransport and LongPollingTransport
private static readonly Action<ILogger, DateTime, string, int, Uri, Exception> _sendingMessages =
LoggerMessage.Define<DateTime, string, int, Uri>(LogLevel.Debug, 9, "{time}: Connection Id {connectionId}: Sending {count} message(s) to the server using url: {url}.");
LoggerMessage.Define<DateTime, string, int, Uri>(LogLevel.Debug, new EventId(9, nameof(SendingMessages)), "{time}: Connection Id {connectionId}: Sending {count} message(s) to the server using url: {url}.");
private static readonly Action<ILogger, DateTime, string, Exception> _sentSuccessfully =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 10, "{time}: Connection Id {connectionId}: Message(s) sent successfully.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(10, nameof(SentSuccessfully)), "{time}: Connection Id {connectionId}: Message(s) sent successfully.");
private static readonly Action<ILogger, DateTime, string, Exception> _noMessages =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 11, "{time}: Connection Id {connectionId}: No messages in batch to send.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(11, nameof(NoMessages)), "{time}: Connection Id {connectionId}: No messages in batch to send.");
private static readonly Action<ILogger, DateTime, string, Uri, Exception> _errorSending =
LoggerMessage.Define<DateTime, string, Uri>(LogLevel.Error, 12, "{time}: Connection Id {connectionId}: Error while sending to '{url}'.");
LoggerMessage.Define<DateTime, string, Uri>(LogLevel.Error, new EventId(12, nameof(ErrorSending)), "{time}: Connection Id {connectionId}: Error while sending to '{url}'.");
// Category: ServerSentEventsTransport
private static readonly Action<ILogger, DateTime, string, Exception> _eventStreamEnded =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 13, "{time}: Connection Id {connectionId}: Server-Sent Event Stream ended.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(13, nameof(EventStreamEnded)), "{time}: Connection Id {connectionId}: Server-Sent Event Stream ended.");
// Category: LongPollingTransport
private static readonly Action<ILogger, DateTime, string, Exception> _closingConnection =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 13, "{time}: Connection Id {connectionId}: The server is closing the connection.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(13, nameof(ClosingConnection)), "{time}: Connection Id {connectionId}: The server is closing the connection.");
private static readonly Action<ILogger, DateTime, string, Exception> _receivedMessages =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 14, "{time}: Connection Id {connectionId}: Received messages from the server.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(14, nameof(ReceivedMessages)), "{time}: Connection Id {connectionId}: Received messages from the server.");
private static readonly Action<ILogger, DateTime, string, Uri, Exception> _errorPolling =
LoggerMessage.Define<DateTime, string, Uri>(LogLevel.Error, 15, "{time}: Connection Id {connectionId}: Error while polling '{pollUrl}'.");
LoggerMessage.Define<DateTime, string, Uri>(LogLevel.Error, new EventId(15, nameof(ErrorPolling)), "{time}: Connection Id {connectionId}: Error while polling '{pollUrl}'.");
// Category: HttpConnection
private static readonly Action<ILogger, DateTime, Exception> _httpConnectionStarting =
LoggerMessage.Define<DateTime>(LogLevel.Debug, 0, "{time}: Starting connection.");
LoggerMessage.Define<DateTime>(LogLevel.Debug, new EventId(0, nameof(HttpConnectionStarting)), "{time}: Starting connection.");
private static readonly Action<ILogger, DateTime, string, Exception> _httpConnectionClosed =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 1, "{time}: Connection Id {connectionId}: Connection was closed from a different thread.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(1, nameof(HttpConnectionClosed)), "{time}: Connection Id {connectionId}: Connection was closed from a different thread.");
private static readonly Action<ILogger, DateTime, string, string, Uri, Exception> _startingTransport =
LoggerMessage.Define<DateTime, string, string, Uri>(LogLevel.Debug, 2, "{time}: Connection Id {connectionId}: Starting transport '{transport}' with Url: {url}.");
LoggerMessage.Define<DateTime, string, string, Uri>(LogLevel.Debug, new EventId(2, nameof(StartingTransport)), "{time}: Connection Id {connectionId}: Starting transport '{transport}' with Url: {url}.");
private static readonly Action<ILogger, DateTime, string, Exception> _raiseConnected =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 3, "{time}: Connection Id {connectionId}: Raising Connected event.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(3, nameof(RaiseConnected)), "{time}: Connection Id {connectionId}: Raising Connected event.");
private static readonly Action<ILogger, DateTime, string, Exception> _processRemainingMessages =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 4, "{time}: Connection Id {connectionId}: Ensuring all outstanding messages are processed.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(4, nameof(ProcessRemainingMessages)), "{time}: Connection Id {connectionId}: Ensuring all outstanding messages are processed.");
private static readonly Action<ILogger, DateTime, string, Exception> _drainEvents =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 5, "{time}: Connection Id {connectionId}: Draining event queue.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(5, nameof(DrainEvents)), "{time}: Connection Id {connectionId}: Draining event queue.");
private static readonly Action<ILogger, DateTime, string, Exception> _raiseClosed =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 6, "{time}: Connection Id {connectionId}: Raising Closed event.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(6, nameof(RaiseClosed)), "{time}: Connection Id {connectionId}: Raising Closed event.");
private static readonly Action<ILogger, DateTime, Uri, Exception> _establishingConnection =
LoggerMessage.Define<DateTime, Uri>(LogLevel.Debug, 7, "{time}: Establishing Connection at: {url}.");
LoggerMessage.Define<DateTime, Uri>(LogLevel.Debug, new EventId(7, nameof(EstablishingConnection)), "{time}: Establishing Connection at: {url}.");
private static readonly Action<ILogger, DateTime, Uri, Exception> _errorWithNegotiation =
LoggerMessage.Define<DateTime, Uri>(LogLevel.Error, 8, "{time}: Failed to start connection. Error getting negotiation response from '{url}'.");
LoggerMessage.Define<DateTime, Uri>(LogLevel.Error, new EventId(8, nameof(ErrorWithNegotiation)), "{time}: Failed to start connection. Error getting negotiation response from '{url}'.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _errorStartingTransport =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Error, 9, "{time}: Connection Id {connectionId}: Failed to start connection. Error starting transport '{transport}'.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Error, new EventId(9, nameof(ErrorStartingTransport)), "{time}: Connection Id {connectionId}: Failed to start connection. Error starting transport '{transport}'.");
private static readonly Action<ILogger, DateTime, string, Exception> _httpReceiveStarted =
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, 10, "{time}: Connection Id {connectionId}: Beginning receive loop.");
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, new EventId(10, nameof(HttpReceiveStarted)), "{time}: Connection Id {connectionId}: Beginning receive loop.");
private static readonly Action<ILogger, DateTime, string, Exception> _skipRaisingReceiveEvent =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 11, "{time}: Connection Id {connectionId}: Message received but connection is not connected. Skipping raising Received event.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(11, nameof(SkipRaisingReceiveEvent)), "{time}: Connection Id {connectionId}: Message received but connection is not connected. Skipping raising Received event.");
private static readonly Action<ILogger, DateTime, string, Exception> _scheduleReceiveEvent =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 12, "{time}: Connection Id {connectionId}: Scheduling raising Received event.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(12, nameof(ScheduleReceiveEvent)), "{time}: Connection Id {connectionId}: Scheduling raising Received event.");
private static readonly Action<ILogger, DateTime, string, Exception> _raiseReceiveEvent =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 13, "{time}: Connection Id {connectionId}: Raising Received event.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(13, nameof(RaiseReceiveEvent)), "{time}: Connection Id {connectionId}: Raising Received event.");
private static readonly Action<ILogger, DateTime, string, Exception> _failedReadingMessage =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 14, "{time}: Connection Id {connectionId}: Could not read message.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(14, nameof(FailedReadingMessage)), "{time}: Connection Id {connectionId}: Could not read message.");
private static readonly Action<ILogger, DateTime, string, Exception> _errorReceiving =
LoggerMessage.Define<DateTime, string>(LogLevel.Error, 15, "{time}: Connection Id {connectionId}: Error receiving message.");
LoggerMessage.Define<DateTime, string>(LogLevel.Error, new EventId(15, nameof(ErrorReceiving)), "{time}: Connection Id {connectionId}: Error receiving message.");
private static readonly Action<ILogger, DateTime, string, Exception> _endReceive =
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, 16, "{time}: Connection Id {connectionId}: Ending receive loop.");
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, new EventId(16, nameof(EndReceive)), "{time}: Connection Id {connectionId}: Ending receive loop.");
private static readonly Action<ILogger, DateTime, string, Exception> _sendingMessage =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 17, "{time}: Connection Id {connectionId}: Sending message.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(17, nameof(SendingMessage)), "{time}: Connection Id {connectionId}: Sending message.");
private static readonly Action<ILogger, DateTime, string, Exception> _stoppingClient =
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 18, "{time}: Connection Id {connectionId}: Stopping client.");
LoggerMessage.Define<DateTime, string>(LogLevel.Information, new EventId(18, nameof(StoppingClient)), "{time}: Connection Id {connectionId}: Stopping client.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _exceptionThrownFromHandler =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Error, 19, "{time}: Connection Id {connectionId}: An exception was thrown from the '{eventHandlerName}' event handler.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Error, new EventId(19, nameof(ExceptionThrownFromHandler)), "{time}: Connection Id {connectionId}: An exception was thrown from the '{eventHandlerName}' event handler.");
public static void StartTransport(this ILogger logger, string connectionId, TransferMode transferMode)
@ -514,7 +514,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal
}
}
public static void ExceptionThrownFromEventHandler(this ILogger logger, string connectionId, string eventHandlerName, Exception exception)
public static void ExceptionThrownFromHandler(this ILogger logger, string connectionId, string eventHandlerName, Exception exception)
{
if (logger.IsEnabled(LogLevel.Error))
{

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -11,91 +11,91 @@ namespace Microsoft.AspNetCore.Sockets.Internal
{
// Category: LongPollingTransport
private static readonly Action<ILogger, DateTime, string, string, Exception> _longPolling204 =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Information, 0, "{time}: Connection Id {connectionId}, Request Id {requestId}: Terminating Long Polling connection by sending 204 response.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Information, new EventId(0, nameof(LongPolling204)), "{time}: Connection Id {connectionId}, Request Id {requestId}: Terminating Long Polling connection by sending 204 response.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _pollTimedOut =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Information, 1, "{time}: Connection Id {connectionId}, Request Id {requestId}: Poll request timed out. Sending 200 response to connection.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Information, new EventId(1, nameof(PollTimedOut)), "{time}: Connection Id {connectionId}, Request Id {requestId}: Poll request timed out. Sending 200 response to connection.");
private static readonly Action<ILogger, DateTime, string, string, int, Exception> _longPollingWritingMessage =
LoggerMessage.Define<DateTime, string, string, int>(LogLevel.Debug, 2, "{time}: Connection Id {connectionId}, Request Id {requestId}: Writing a {count} byte message to connection.");
LoggerMessage.Define<DateTime, string, string, int>(LogLevel.Debug, new EventId(2, nameof(LongPollingWritingMessage)), "{time}: Connection Id {connectionId}, Request Id {requestId}: Writing a {count} byte message to connection.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _longPollingDisconnected =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, 3, "{time}: Connection Id {connectionId}, Request Id {requestId}: Client disconnected from Long Polling endpoint for connection.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, new EventId(3, nameof(LongPollingDisconnected)), "{time}: Connection Id {connectionId}, Request Id {requestId}: Client disconnected from Long Polling endpoint for connection.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _longPollingTerminated =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Error, 4, "{time}: Connection Id {connectionId}, Request Id {requestId}: Long Polling transport was terminated due to an error on connection.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Error, new EventId(4, nameof(LongPollingTerminated)), "{time}: Connection Id {connectionId}, Request Id {requestId}: Long Polling transport was terminated due to an error on connection.");
// Category: HttpConnectionDispatcher
private static readonly Action<ILogger, DateTime, string, Exception> _connectionDisposed =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 0, "{time}: Connection Id {connectionId} was disposed.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(0, nameof(ConnectionDisposed)), "{time}: Connection Id {connectionId} was disposed.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _connectionAlreadyActive =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, 1, "{time}: Connection Id {connectionId} is already active via {requestId}.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, new EventId(1, nameof(ConnectionAlreadyActive)), "{time}: Connection Id {connectionId} is already active via {requestId}.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _pollCanceled =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, 2, "{time}: Previous poll canceled for {connectionId} on {requestId}.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, new EventId(2, nameof(PollCanceled)), "{time}: Previous poll canceled for {connectionId} on {requestId}.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _establishedConnection =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, 3, "{time}: Connection Id {connectionId}, Request Id {requestId}: Establishing new connection.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, new EventId(3, nameof(EstablishedConnection)), "{time}: Connection Id {connectionId}, Request Id {requestId}: Establishing new connection.");
private static readonly Action<ILogger, DateTime, string, string, Exception> _resumingConnection =
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, 4, "{time}: Connection Id {connectionId}, Request Id {requestId}: Resuming existing connection.");
LoggerMessage.Define<DateTime, string, string>(LogLevel.Debug, new EventId(4, nameof(ResumingConnection)), "{time}: Connection Id {connectionId}, Request Id {requestId}: Resuming existing connection.");
private static readonly Action<ILogger, DateTime, string, int, Exception> _receivedBytes =
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, 5, "{time}: Connection Id {connectionId}: Received {count} bytes.");
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, new EventId(5, nameof(ReceivedBytes)), "{time}: Connection Id {connectionId}: Received {count} bytes.");
private static readonly Action<ILogger, DateTime, string, TransportType, Exception> _transportNotSupported =
LoggerMessage.Define<DateTime, string, TransportType>(LogLevel.Debug, 6, "{time}: Connection Id {connectionId}: {transportType} transport not supported by this endpoint type.");
LoggerMessage.Define<DateTime, string, TransportType>(LogLevel.Debug, new EventId(6, nameof(TransportNotSupported)), "{time}: Connection Id {connectionId}: {transportType} transport not supported by this endpoint type.");
private static readonly Action<ILogger, DateTime, string, TransportType, TransportType, Exception> _cannotChangeTransport =
LoggerMessage.Define<DateTime, string, TransportType, TransportType>(LogLevel.Debug, 7, "{time}: Connection Id {connectionId}: Cannot change transports mid-connection; currently using {transportType}, requesting {requestedTransport}.");
LoggerMessage.Define<DateTime, string, TransportType, TransportType>(LogLevel.Debug, new EventId(7, nameof(CannotChangeTransport)), "{time}: Connection Id {connectionId}: Cannot change transports mid-connection; currently using {transportType}, requesting {requestedTransport}.");
private static readonly Action<ILogger, DateTime, string, Exception> _negotiationRequest =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 8, "{time}: Connection Id {connectionId}: Sending negotiation response.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(8, nameof(NegotiationRequest)), "{time}: Connection Id {connectionId}: Sending negotiation response.");
// Category: WebSocketsTransport
private static readonly Action<ILogger, DateTime, string, Exception> _socketOpened =
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 0, "{time}: Connection Id {connectionId}: Socket opened.");
LoggerMessage.Define<DateTime, string>(LogLevel.Information, new EventId(0, nameof(SocketOpened)), "{time}: Connection Id {connectionId}: Socket opened.");
private static readonly Action<ILogger, DateTime, string, Exception> _socketClosed =
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 1, "{time}: Connection Id {connectionId}: Socket closed.");
LoggerMessage.Define<DateTime, string>(LogLevel.Information, new EventId(1, nameof(SocketClosed)), "{time}: Connection Id {connectionId}: Socket closed.");
private static readonly Action<ILogger, DateTime, string, WebSocketCloseStatus?, string, Exception> _clientClosed =
LoggerMessage.Define<DateTime, string, WebSocketCloseStatus?, string>(LogLevel.Debug, 2, "{time}: Connection Id {connectionId}: Client closed connection with status code '{status}' ({description}). Signaling end-of-input to application..");
LoggerMessage.Define<DateTime, string, WebSocketCloseStatus?, string>(LogLevel.Debug, new EventId(2, nameof(ClientClosed)), "{time}: Connection Id {connectionId}: Client closed connection with status code '{status}' ({description}). Signaling end-of-input to application..");
private static readonly Action<ILogger, DateTime, string, Exception> _waitingForSend =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 3, "{time}: Connection Id {connectionId}: Waiting for the application to finish sending data.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(3, nameof(WaitingForSend)), "{time}: Connection Id {connectionId}: Waiting for the application to finish sending data.");
private static readonly Action<ILogger, DateTime, string, Exception> _failedSending =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 4, "{time}: Connection Id {connectionId}: Application failed during sending. Sending InternalServerError close frame.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(4, nameof(FailedSending)), "{time}: Connection Id {connectionId}: Application failed during sending. Sending InternalServerError close frame.");
private static readonly Action<ILogger, DateTime, string, Exception> _finishedSending =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 5, "{time}: Connection Id {connectionId}: Application finished sending. Sending close frame.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(5, nameof(FinishedSending)), "{time}: Connection Id {connectionId}: Application finished sending. Sending close frame.");
private static readonly Action<ILogger, DateTime, string, Exception> _waitingForClose =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 6, "{time}: Connection Id {connectionId}: Waiting for the client to close the socket.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(6, nameof(WaitingForClose)), "{time}: Connection Id {connectionId}: Waiting for the client to close the socket.");
private static readonly Action<ILogger, DateTime, string, Exception> _closeTimedOut =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 7, "{time}: Connection Id {connectionId}: Timed out waiting for client to send the close frame, aborting the connection.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(7, nameof(CloseTimedOut)), "{time}: Connection Id {connectionId}: Timed out waiting for client to send the close frame, aborting the connection.");
private static readonly Action<ILogger, DateTime, string, WebSocketMessageType, int, bool, Exception> _messageReceived =
LoggerMessage.Define<DateTime, string, WebSocketMessageType, int, bool>(LogLevel.Debug, 8, "{time}: Connection Id {connectionId}: Message received. Type: {messageType}, size: {size}, EndOfMessage: {endOfMessage}.");
LoggerMessage.Define<DateTime, string, WebSocketMessageType, int, bool>(LogLevel.Debug, new EventId(8, nameof(MessageReceived)), "{time}: Connection Id {connectionId}: Message received. Type: {messageType}, size: {size}, EndOfMessage: {endOfMessage}.");
private static readonly Action<ILogger, DateTime, string, int, Exception> _messageToApplication =
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, 9, "{time}: Connection Id {connectionId}: Passing message to application. Payload size: {size}.");
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, new EventId(9, nameof(MessageToApplication)), "{time}: Connection Id {connectionId}: Passing message to application. Payload size: {size}.");
private static readonly Action<ILogger, DateTime, string, int, Exception> _sendPayload =
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, 10, "{time}: Connection Id {connectionId}: Sending payload: {size} bytes.");
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, new EventId(10, nameof(SendPayload)), "{time}: Connection Id {connectionId}: Sending payload: {size} bytes.");
private static readonly Action<ILogger, DateTime, string, Exception> _errorWritingFrame =
LoggerMessage.Define<DateTime, string>(LogLevel.Error, 11, "{time}: Connection Id {connectionId}: Error writing frame.");
LoggerMessage.Define<DateTime, string>(LogLevel.Error, new EventId(11, nameof(ErrorWritingFrame)), "{time}: Connection Id {connectionId}: Error writing frame.");
private static readonly Action<ILogger, DateTime, string, Exception> _sendFailed =
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, 12, "{time}: Connection Id {connectionId}: Socket failed to send.");
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, new EventId(12, nameof(SendFailed)), "{time}: Connection Id {connectionId}: Socket failed to send.");
// Category: ServerSentEventsTransport
private static readonly Action<ILogger, DateTime, string, int, Exception> _sseWritingMessage =
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, 0, "{time}: Connection Id {connectionId}: Writing a {count} byte message.");
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, new EventId(0, nameof(SSEWritingMessage)), "{time}: Connection Id {connectionId}: Writing a {count} byte message.");
public static void LongPolling204(this ILogger logger, string connectionId, string requestId)
{

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -10,16 +10,16 @@ namespace Microsoft.AspNetCore.Sockets.Internal
{
// Category: ConnectionManager
private static readonly Action<ILogger, DateTime, string, Exception> _createdNewConnection =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 0, "{time}: ConnectionId {connectionId}: New connection created.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(0, nameof(CreatedNewConnection)), "{time}: ConnectionId {connectionId}: New connection created.");
private static readonly Action<ILogger, DateTime, string, Exception> _removedConnection =
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 1, "{time}: ConnectionId {connectionId}: Removing connection from the list of connections.");
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, new EventId(1, nameof(RemovedConnection)), "{time}: ConnectionId {connectionId}: Removing connection from the list of connections.");
private static readonly Action<ILogger, DateTime, string, Exception> _failedDispose =
LoggerMessage.Define<DateTime, string>(LogLevel.Error, 2, "{time}: ConnectionId {connectionId}: Failed disposing connection.");
LoggerMessage.Define<DateTime, string>(LogLevel.Error, new EventId(2, nameof(FailedDispose)), "{time}: ConnectionId {connectionId}: Failed disposing connection.");
private static readonly Action<ILogger, DateTime, string, Exception> _connectionReset =
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, 3, "{time}: ConnectionId {connectionId}: Connection was reset.");
LoggerMessage.Define<DateTime, string>(LogLevel.Trace, new EventId(3, nameof(ConnectionReset)), "{time}: ConnectionId {connectionId}: Connection was reset.");
public static void CreatedNewConnection(this ILogger logger, string connectionId)
{