// 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 HttpConnectionManager { private static class Log { private static readonly Action _createdNewConnection = LoggerMessage.Define(LogLevel.Debug, new EventId(1, "CreatedNewConnection"), "New connection {TransportConnectionId} created."); private static readonly Action _removedConnection = LoggerMessage.Define(LogLevel.Debug, new EventId(2, "RemovedConnection"), "Removing connection {TransportConnectionId} from the list of connections."); private static readonly Action _failedDispose = LoggerMessage.Define(LogLevel.Error, new EventId(3, "FailedDispose"), "Failed disposing connection {TransportConnectionId}."); private static readonly Action _connectionReset = LoggerMessage.Define(LogLevel.Trace, new EventId(4, "ConnectionReset"), "Connection {TransportConnectionId} was reset."); private static readonly Action _connectionTimedOut = LoggerMessage.Define(LogLevel.Trace, new EventId(5, "ConnectionTimedOut"), "Connection {TransportConnectionId} timed out."); private static readonly Action _scanningConnections = LoggerMessage.Define(LogLevel.Trace, new EventId(6, "ScanningConnections"), "Scanning connections."); private static readonly Action _scannedConnections = LoggerMessage.Define(LogLevel.Trace, new EventId(7, "ScannedConnections"), "Scanned connections in {Duration}."); public static void CreatedNewConnection(ILogger logger, string connectionId) { _createdNewConnection(logger, connectionId, null); } public static void RemovedConnection(ILogger logger, string connectionId) { _removedConnection(logger, connectionId, null); } public static void FailedDispose(ILogger logger, string connectionId, Exception exception) { _failedDispose(logger, connectionId, exception); } public static void ConnectionTimedOut(ILogger logger, string connectionId) { _connectionTimedOut(logger, connectionId, null); } public static void ConnectionReset(ILogger logger, string connectionId, Exception exception) { _connectionReset(logger, connectionId, exception); } public static void ScanningConnections(ILogger logger) { _scanningConnections(logger, null); } public static void ScannedConnections(ILogger logger, TimeSpan duration) { _scannedConnections(logger, duration, null); } } } }