diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts b/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts index fa6f8f93fa..790cf57d02 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts +++ b/client-ts/Microsoft.AspNetCore.SignalR.Client.TS/HubConnection.ts @@ -123,7 +123,9 @@ export class HubConnection { await this.connection.send( TextMessageFormat.write( - JSON.stringify({ protocol: this.protocol.name}))); + JSON.stringify({ protocol: this.protocol.name }))); + + this.logger.log(LogLevel.Information, `Using HubProtocol '${this.protocol.name}'.`); if (requestedTransferMode === TransferMode.Binary && actualTransferMode === TransferMode.Text) { this.protocol = new Base64EncodedHubProtocol(this.protocol); diff --git a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs index cb86c85c3a..956c9bd97c 100644 --- a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs +++ b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs @@ -94,6 +94,8 @@ namespace Microsoft.AspNetCore.SignalR.Client _protocolReaderWriter = new HubProtocolReaderWriter(_protocol, GetDataEncoder(requestedTransferMode, actualTransferMode)); + _logger.HubProtocol(_protocol.Name); + using (var memoryStream = new MemoryStream()) { NegotiationProtocol.WriteMessage(new NegotiationMessage(_protocol.Name), memoryStream); diff --git a/src/Microsoft.AspNetCore.SignalR.Client.Core/Internal/SignalRClientLoggerExtensions.cs b/src/Microsoft.AspNetCore.SignalR.Client.Core/Internal/SignalRClientLoggerExtensions.cs index dc94a1b381..08068fc3b5 100644 --- a/src/Microsoft.AspNetCore.SignalR.Client.Core/Internal/SignalRClientLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.SignalR.Client.Core/Internal/SignalRClientLoggerExtensions.cs @@ -23,10 +23,10 @@ namespace Microsoft.AspNetCore.SignalR.Client.Internal LoggerMessage.Define(LogLevel.Trace, 3, "Issuing Invocation '{invocationId}': {returnType} {methodName}({args})."); private static readonly Action _sendInvocation = - LoggerMessage.Define(LogLevel.Information, 4, "Sending Invocation '{invocationId}'."); + LoggerMessage.Define(LogLevel.Debug, 4, "Sending Invocation '{invocationId}'."); private static readonly Action _sendInvocationCompleted = - LoggerMessage.Define(LogLevel.Information, 5, "Sending Invocation '{invocationId}' completed."); + LoggerMessage.Define(LogLevel.Debug, 5, "Sending Invocation '{invocationId}' completed."); private static readonly Action _sendInvocationFailed = LoggerMessage.Define(LogLevel.Error, 6, "Sending Invocation '{invocationId}' failed."); @@ -76,6 +76,9 @@ namespace Microsoft.AspNetCore.SignalR.Client.Internal private static readonly Action _receivedUnexpectedResponse = LoggerMessage.Define(LogLevel.Error, 21, "Unsolicited response received for invocation '{invocationId}'."); + private static readonly Action _hubProtocol = + LoggerMessage.Define(LogLevel.Information, 22, "Using HubProtocol '{protocol}'."); + // Category: Streaming and NonStreaming private static readonly Action _invocationCreated = LoggerMessage.Define(LogLevel.Trace, 0, "Invocation {invocationId} created."); @@ -218,6 +221,11 @@ namespace Microsoft.AspNetCore.SignalR.Client.Internal _receivedUnexpectedResponse(logger, invocationId, null); } + public static void HubProtocol(this ILogger logger, string hubProtocol) + { + _hubProtocol(logger, hubProtocol, null); + } + public static void InvocationCreated(this ILogger logger, string invocationId) { _invocationCreated(logger, invocationId, null); diff --git a/src/Microsoft.AspNetCore.SignalR.Core/HubEndPoint.cs b/src/Microsoft.AspNetCore.SignalR.Core/HubEndPoint.cs index d903973e4f..29066f3c99 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/HubEndPoint.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/HubEndPoint.cs @@ -143,6 +143,8 @@ namespace Microsoft.AspNetCore.SignalR connection.ProtocolReaderWriter = new HubProtocolReaderWriter(protocol, dataEncoder); + _logger.LogInformation("Using HubProtocol '{protocol}'.", protocol.Name); + return true; } } diff --git a/src/Microsoft.AspNetCore.Sockets.Client.Http/Internal/SocketClientLoggerExtensions.cs b/src/Microsoft.AspNetCore.Sockets.Client.Http/Internal/SocketClientLoggerExtensions.cs index 9ee629e20e..dfec2e0726 100644 --- a/src/Microsoft.AspNetCore.Sockets.Client.Http/Internal/SocketClientLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Sockets.Client.Http/Internal/SocketClientLoggerExtensions.cs @@ -17,10 +17,10 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal LoggerMessage.Define(LogLevel.Debug, 1, "{time}: Connection Id {connectionId}: Transport stopped."); private static readonly Action _startReceive = - LoggerMessage.Define(LogLevel.Information, 2, "{time}: Connection Id {connectionId}: Starting receive loop."); + LoggerMessage.Define(LogLevel.Debug, 2, "{time}: Connection Id {connectionId}: Starting receive loop."); private static readonly Action _receiveStopped = - LoggerMessage.Define(LogLevel.Information, 3, "{time}: Connection Id {connectionId}: Receive loop stopped."); + LoggerMessage.Define(LogLevel.Debug, 3, "{time}: Connection Id {connectionId}: Receive loop stopped."); private static readonly Action _receiveCanceled = LoggerMessage.Define(LogLevel.Debug, 4, "{time}: Connection Id {connectionId}: Receive loop canceled."); @@ -29,10 +29,10 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal LoggerMessage.Define(LogLevel.Information, 5, "{time}: Connection Id {connectionId}: Transport is stopping."); private static readonly Action _sendStarted = - LoggerMessage.Define(LogLevel.Information, 6, "{time}: Connection Id {connectionId}: Starting the send loop."); + LoggerMessage.Define(LogLevel.Debug, 6, "{time}: Connection Id {connectionId}: Starting the send loop."); private static readonly Action _sendStopped = - LoggerMessage.Define(LogLevel.Information, 7, "{time}: Connection Id {connectionId}: Send loop stopped."); + LoggerMessage.Define(LogLevel.Debug, 7, "{time}: Connection Id {connectionId}: Send loop stopped."); private static readonly Action _sendCanceled = LoggerMessage.Define(LogLevel.Debug, 8, "{time}: Connection Id {connectionId}: Send loop canceled."); @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal LoggerMessage.Define(LogLevel.Debug, 10, "{time}: Connection Id {connectionId}: Message received. Type: {messageType}, size: {count}, EndOfMessage: {endOfMessage}."); private static readonly Action _messageToApp = - LoggerMessage.Define(LogLevel.Information, 11, "{time}: Connection Id {connectionId}: Passing message to application. Payload size: {count}."); + LoggerMessage.Define(LogLevel.Debug, 11, "{time}: Connection Id {connectionId}: Passing message to application. Payload size: {count}."); private static readonly Action _receivedFromApp = LoggerMessage.Define(LogLevel.Debug, 12, "{time}: Connection Id {connectionId}: Received message from application. Payload size: {count}."); @@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal public static void StartReceive(this ILogger logger, string connectionId) { - if (logger.IsEnabled(LogLevel.Information)) + if (logger.IsEnabled(LogLevel.Debug)) { _startReceive(logger, DateTime.Now, connectionId, null); } @@ -204,7 +204,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal public static void MessageToApp(this ILogger logger, string connectionId, int count) { - if (logger.IsEnabled(LogLevel.Information)) + if (logger.IsEnabled(LogLevel.Debug)) { _messageToApp(logger, DateTime.Now, connectionId, count, null); } @@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal public static void ReceiveStopped(this ILogger logger, string connectionId) { - if (logger.IsEnabled(LogLevel.Information)) + if (logger.IsEnabled(LogLevel.Debug)) { _receiveStopped(logger, DateTime.Now, connectionId, null); } @@ -228,7 +228,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal public static void SendStarted(this ILogger logger, string connectionId) { - if (logger.IsEnabled(LogLevel.Information)) + if (logger.IsEnabled(LogLevel.Debug)) { _sendStarted(logger, DateTime.Now, connectionId, null); } @@ -268,7 +268,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal public static void SendStopped(this ILogger logger, string connectionId) { - if (logger.IsEnabled(LogLevel.Information)) + if (logger.IsEnabled(LogLevel.Debug)) { _sendStopped(logger, DateTime.Now, connectionId, null); }