|
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
| 2 | +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
| 3 | + |
| 4 | +using System; |
| 5 | +using Microsoft.Extensions.Logging; |
| 6 | + |
| 7 | +namespace Microsoft.AspNetCore.Http.Connections |
| 8 | +{ |
| 9 | + public partial class HttpConnectionManager |
| 10 | + { |
| 11 | + private static class Log |
| 12 | + { |
| 13 | + private static readonly Action<ILogger, string, Exception> _createdNewConnection = |
| 14 | + LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "CreatedNewConnection"), "New connection {TransportConnectionId} created."); |
| 15 | + |
| 16 | + private static readonly Action<ILogger, string, Exception> _removedConnection = |
| 17 | + LoggerMessage.Define<string>(LogLevel.Debug, new EventId(2, "RemovedConnection"), "Removing connection {TransportConnectionId} from the list of connections."); |
| 18 | + |
| 19 | + private static readonly Action<ILogger, string, Exception> _failedDispose = |
| 20 | + LoggerMessage.Define<string>(LogLevel.Error, new EventId(3, "FailedDispose"), "Failed disposing connection {TransportConnectionId}."); |
| 21 | + |
| 22 | + private static readonly Action<ILogger, string, Exception> _connectionReset = |
| 23 | + LoggerMessage.Define<string>(LogLevel.Trace, new EventId(4, "ConnectionReset"), "Connection {TransportConnectionId} was reset."); |
| 24 | + |
| 25 | + private static readonly Action<ILogger, string, Exception> _connectionTimedOut = |
| 26 | + LoggerMessage.Define<string>(LogLevel.Trace, new EventId(5, "ConnectionTimedOut"), "Connection {TransportConnectionId} timed out."); |
| 27 | + |
| 28 | + private static readonly Action<ILogger, Exception> _scanningConnections = |
| 29 | + LoggerMessage.Define(LogLevel.Trace, new EventId(6, "ScanningConnections"), "Scanning connections."); |
| 30 | + |
| 31 | + private static readonly Action<ILogger, TimeSpan, Exception> _scannedConnections = |
| 32 | + LoggerMessage.Define<TimeSpan>(LogLevel.Trace, new EventId(7, "ScannedConnections"), "Scanned connections in {Duration}."); |
| 33 | + |
| 34 | + public static void CreatedNewConnection(ILogger logger, string connectionId) |
| 35 | + { |
| 36 | + _createdNewConnection(logger, connectionId, null); |
| 37 | + } |
| 38 | + |
| 39 | + public static void RemovedConnection(ILogger logger, string connectionId) |
| 40 | + { |
| 41 | + _removedConnection(logger, connectionId, null); |
| 42 | + } |
| 43 | + |
| 44 | + public static void FailedDispose(ILogger logger, string connectionId, Exception exception) |
| 45 | + { |
| 46 | + _failedDispose(logger, connectionId, exception); |
| 47 | + } |
| 48 | + |
| 49 | + public static void ConnectionTimedOut(ILogger logger, string connectionId) |
| 50 | + { |
| 51 | + _connectionTimedOut(logger, connectionId, null); |
| 52 | + } |
| 53 | + |
| 54 | + public static void ConnectionReset(ILogger logger, string connectionId, Exception exception) |
| 55 | + { |
| 56 | + _connectionReset(logger, connectionId, exception); |
| 57 | + } |
| 58 | + |
| 59 | + public static void ScanningConnections(ILogger logger) |
| 60 | + { |
| 61 | + _scanningConnections(logger, null); |
| 62 | + } |
| 63 | + |
| 64 | + public static void ScannedConnections(ILogger logger, TimeSpan duration) |
| 65 | + { |
| 66 | + _scannedConnections(logger, duration, null); |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments