// 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; using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Http.Connections { public partial class HttpConnectionDispatcher { private static class Log { private static readonly Action _connectionDisposed = LoggerMessage.Define(LogLevel.Debug, new EventId(1, "ConnectionDisposed"), "Connection Id {TransportConnectionId} was disposed."); private static readonly Action _connectionAlreadyActive = LoggerMessage.Define(LogLevel.Debug, new EventId(2, "ConnectionAlreadyActive"), "Connection Id {TransportConnectionId} is already active via {RequestId}."); private static readonly Action _pollCanceled = LoggerMessage.Define(LogLevel.Trace, new EventId(3, "PollCanceled"), "Previous poll canceled for {TransportConnectionId} on {RequestId}."); private static readonly Action _establishedConnection = LoggerMessage.Define(LogLevel.Debug, new EventId(4, "EstablishedConnection"), "Establishing new connection."); private static readonly Action _resumingConnection = LoggerMessage.Define(LogLevel.Debug, new EventId(5, "ResumingConnection"), "Resuming existing connection."); private static readonly Action _receivedBytes = LoggerMessage.Define(LogLevel.Trace, new EventId(6, "ReceivedBytes"), "Received {Count} bytes."); private static readonly Action _transportNotSupported = LoggerMessage.Define(LogLevel.Debug, new EventId(7, "TransportNotSupported"), "{TransportType} transport not supported by this connection handler."); private static readonly Action _cannotChangeTransport = LoggerMessage.Define(LogLevel.Error, new EventId(8, "CannotChangeTransport"), "Cannot change transports mid-connection; currently using {TransportType}, requesting {RequestedTransport}."); private static readonly Action _postNotallowedForWebsockets = LoggerMessage.Define(LogLevel.Debug, new EventId(9, "PostNotAllowedForWebSockets"), "POST requests are not allowed for websocket connections."); private static readonly Action _negotiationRequest = LoggerMessage.Define(LogLevel.Debug, new EventId(10, "NegotiationRequest"), "Sending negotiation response."); public static void ConnectionDisposed(ILogger logger, string connectionId) { _connectionDisposed(logger, connectionId, null); } public static void ConnectionAlreadyActive(ILogger logger, string connectionId, string requestId) { _connectionAlreadyActive(logger, connectionId, requestId, null); } public static void PollCanceled(ILogger logger, string connectionId, string requestId) { _pollCanceled(logger, connectionId, requestId, null); } public static void EstablishedConnection(ILogger logger) { _establishedConnection(logger, null); } public static void ResumingConnection(ILogger logger) { _resumingConnection(logger, null); } public static void ReceivedBytes(ILogger logger, long count) { _receivedBytes(logger, count, null); } public static void TransportNotSupported(ILogger logger, HttpTransportType transport) { _transportNotSupported(logger, transport, null); } public static void CannotChangeTransport(ILogger logger, HttpTransportType transport, HttpTransportType requestTransport) { _cannotChangeTransport(logger, transport, requestTransport, null); } public static void PostNotAllowedForWebSockets(ILogger logger) { _postNotallowedForWebsockets(logger, null); } public static void NegotiationRequest(ILogger logger) { _negotiationRequest(logger, null); } } } }