Reduce C# client logging and add HubProtocol log (#857)
This commit is contained in:
parent
35683fb2b8
commit
2d4b2239a9
|
|
@ -123,7 +123,9 @@ export class HubConnection {
|
|||
|
||||
await this.connection.send(
|
||||
TextMessageFormat.write(
|
||||
JSON.stringify(<NegotiationMessage>{ protocol: this.protocol.name})));
|
||||
JSON.stringify(<NegotiationMessage>{ 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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ namespace Microsoft.AspNetCore.SignalR.Client.Internal
|
|||
LoggerMessage.Define<string, string, string, string>(LogLevel.Trace, 3, "Issuing Invocation '{invocationId}': {returnType} {methodName}({args}).");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _sendInvocation =
|
||||
LoggerMessage.Define<string>(LogLevel.Information, 4, "Sending Invocation '{invocationId}'.");
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, 4, "Sending Invocation '{invocationId}'.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _sendInvocationCompleted =
|
||||
LoggerMessage.Define<string>(LogLevel.Information, 5, "Sending Invocation '{invocationId}' completed.");
|
||||
LoggerMessage.Define<string>(LogLevel.Debug, 5, "Sending Invocation '{invocationId}' completed.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _sendInvocationFailed =
|
||||
LoggerMessage.Define<string>(LogLevel.Error, 6, "Sending Invocation '{invocationId}' failed.");
|
||||
|
|
@ -76,6 +76,9 @@ namespace Microsoft.AspNetCore.SignalR.Client.Internal
|
|||
private static readonly Action<ILogger, string, Exception> _receivedUnexpectedResponse =
|
||||
LoggerMessage.Define<string>(LogLevel.Error, 21, "Unsolicited response received for invocation '{invocationId}'.");
|
||||
|
||||
private static readonly Action<ILogger, string, Exception> _hubProtocol =
|
||||
LoggerMessage.Define<string>(LogLevel.Information, 22, "Using HubProtocol '{protocol}'.");
|
||||
|
||||
// Category: Streaming and NonStreaming
|
||||
private static readonly Action<ILogger, string, Exception> _invocationCreated =
|
||||
LoggerMessage.Define<string>(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);
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
|
||||
connection.ProtocolReaderWriter = new HubProtocolReaderWriter(protocol, dataEncoder);
|
||||
|
||||
_logger.LogInformation("Using HubProtocol '{protocol}'.", protocol.Name);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal
|
|||
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 1, "{time}: Connection Id {connectionId}: Transport stopped.");
|
||||
|
||||
private static readonly Action<ILogger, DateTime, string, Exception> _startReceive =
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 2, "{time}: Connection Id {connectionId}: Starting receive loop.");
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 2, "{time}: Connection Id {connectionId}: Starting receive loop.");
|
||||
|
||||
private static readonly Action<ILogger, DateTime, string, Exception> _receiveStopped =
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 3, "{time}: Connection Id {connectionId}: Receive loop stopped.");
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 3, "{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.");
|
||||
|
|
@ -29,10 +29,10 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal
|
|||
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 5, "{time}: Connection Id {connectionId}: Transport is stopping.");
|
||||
|
||||
private static readonly Action<ILogger, DateTime, string, Exception> _sendStarted =
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 6, "{time}: Connection Id {connectionId}: Starting the send loop.");
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 6, "{time}: Connection Id {connectionId}: Starting the send loop.");
|
||||
|
||||
private static readonly Action<ILogger, DateTime, string, Exception> _sendStopped =
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Information, 7, "{time}: Connection Id {connectionId}: Send loop stopped.");
|
||||
LoggerMessage.Define<DateTime, string>(LogLevel.Debug, 7, "{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.");
|
||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Sockets.Client.Internal
|
|||
LoggerMessage.Define<DateTime, string, WebSocketMessageType, int, bool>(LogLevel.Debug, 10, "{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.Information, 11, "{time}: Connection Id {connectionId}: Passing message to application. Payload size: {count}.");
|
||||
LoggerMessage.Define<DateTime, string, int>(LogLevel.Debug, 11, "{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}.");
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue