< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: Microsoft.Extensions.Logging.AsyncResponseLoggerExtensions.LogCache<T0, T1, T2>
Assembly: AsyncResponse.Core
File(s): /home/runner/work/AsyncResponse/AsyncResponse/src/AsyncResponse.Core/Logging/AsyncResponseLoggerExtensions.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 367
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
Get(...)100%22100%

File(s)

/home/runner/work/AsyncResponse/AsyncResponse/src/AsyncResponse.Core/Logging/AsyncResponseLoggerExtensions.cs

#LineLine coverage
 1using System.Collections.Concurrent;
 2
 3namespace Microsoft.Extensions.Logging;
 4
 5internal static class AsyncResponseLoggerExtensions
 6{
 7    private static readonly LogDefineOptions Options = new() { SkipEnabledCheck = true };
 8
 9    /// <summary>Runs the LogDebug operation.</summary>
 10    public static void LogDebug(this ILogger logger, string message)
 11        => Log(logger, LogLevel.Debug, exception: null, message);
 12
 13    /// <summary>Runs the LogDebug operation.</summary>
 14    public static void LogDebug<T0>(this ILogger logger, string message, T0 arg0)
 15        => Log(logger, LogLevel.Debug, exception: null, message, arg0);
 16
 17    /// <summary>Runs the LogDebug operation.</summary>
 18    public static void LogDebug<T0, T1>(this ILogger logger, string message, T0 arg0, T1 arg1)
 19        => Log(logger, LogLevel.Debug, exception: null, message, arg0, arg1);
 20
 21    /// <summary>Runs the LogDebug operation.</summary>
 22    public static void LogDebug<T0, T1, T2>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2)
 23        => Log(logger, LogLevel.Debug, exception: null, message, arg0, arg1, arg2);
 24
 25    /// <summary>Runs the LogDebug operation.</summary>
 26    public static void LogDebug<T0, T1, T2, T3>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
 27        => Log(logger, LogLevel.Debug, exception: null, message, arg0, arg1, arg2, arg3);
 28
 29    /// <summary>Runs the LogDebug operation.</summary>
 30    public static void LogDebug<T0, T1, T2, T3, T4>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, T3 a
 31        => Log(logger, LogLevel.Debug, exception: null, message, arg0, arg1, arg2, arg3, arg4);
 32
 33    /// <summary>Runs the LogDebug operation.</summary>
 34    public static void LogDebug<T0, T1, T2, T3, T4, T5>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, 
 35        => Log(logger, LogLevel.Debug, exception: null, message, arg0, arg1, arg2, arg3, arg4, arg5);
 36
 37    /// <summary>Runs the LogDebug operation.</summary>
 38    public static void LogDebug(this ILogger logger, Exception? exception, string message)
 39        => Log(logger, LogLevel.Debug, exception, message);
 40
 41    /// <summary>Runs the LogDebug operation.</summary>
 42    public static void LogDebug<T0>(this ILogger logger, Exception? exception, string message, T0 arg0)
 43        => Log(logger, LogLevel.Debug, exception, message, arg0);
 44
 45    /// <summary>Runs the LogDebug operation.</summary>
 46    public static void LogDebug<T0, T1>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 arg1)
 47        => Log(logger, LogLevel.Debug, exception, message, arg0, arg1);
 48
 49    /// <summary>Runs the LogDebug operation.</summary>
 50    public static void LogDebug<T0, T1, T2>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 arg1,
 51        => Log(logger, LogLevel.Debug, exception, message, arg0, arg1, arg2);
 52
 53    /// <summary>Runs the LogDebug operation.</summary>
 54    public static void LogDebug<T0, T1, T2, T3>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 a
 55        => Log(logger, LogLevel.Debug, exception, message, arg0, arg1, arg2, arg3);
 56
 57    /// <summary>Runs the LogDebug operation.</summary>
 58    public static void LogDebug<T0, T1, T2, T3, T4>(this ILogger logger, Exception? exception, string message, T0 arg0, 
 59        => Log(logger, LogLevel.Debug, exception, message, arg0, arg1, arg2, arg3, arg4);
 60
 61    /// <summary>Runs the LogDebug operation.</summary>
 62    public static void LogDebug<T0, T1, T2, T3, T4, T5>(this ILogger logger, Exception? exception, string message, T0 ar
 63        => Log(logger, LogLevel.Debug, exception, message, arg0, arg1, arg2, arg3, arg4, arg5);
 64
 65    /// <summary>Runs the LogInformation operation.</summary>
 66    public static void LogInformation(this ILogger logger, string message)
 67        => Log(logger, LogLevel.Information, exception: null, message);
 68
 69    /// <summary>Runs the LogInformation operation.</summary>
 70    public static void LogInformation<T0>(this ILogger logger, string message, T0 arg0)
 71        => Log(logger, LogLevel.Information, exception: null, message, arg0);
 72
 73    /// <summary>Runs the LogInformation operation.</summary>
 74    public static void LogInformation<T0, T1>(this ILogger logger, string message, T0 arg0, T1 arg1)
 75        => Log(logger, LogLevel.Information, exception: null, message, arg0, arg1);
 76
 77    /// <summary>Runs the LogInformation operation.</summary>
 78    public static void LogInformation<T0, T1, T2>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2)
 79        => Log(logger, LogLevel.Information, exception: null, message, arg0, arg1, arg2);
 80
 81    /// <summary>Runs the LogInformation operation.</summary>
 82    public static void LogInformation<T0, T1, T2, T3>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, T3
 83        => Log(logger, LogLevel.Information, exception: null, message, arg0, arg1, arg2, arg3);
 84
 85    /// <summary>Runs the LogInformation operation.</summary>
 86    public static void LogInformation<T0, T1, T2, T3, T4>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2
 87        => Log(logger, LogLevel.Information, exception: null, message, arg0, arg1, arg2, arg3, arg4);
 88
 89    /// <summary>Runs the LogInformation operation.</summary>
 90    public static void LogInformation<T0, T1, T2, T3, T4, T5>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 
 91        => Log(logger, LogLevel.Information, exception: null, message, arg0, arg1, arg2, arg3, arg4, arg5);
 92
 93    /// <summary>Runs the LogInformation operation.</summary>
 94    public static void LogInformation(this ILogger logger, Exception? exception, string message)
 95        => Log(logger, LogLevel.Information, exception, message);
 96
 97    /// <summary>Runs the LogInformation operation.</summary>
 98    public static void LogInformation<T0>(this ILogger logger, Exception? exception, string message, T0 arg0)
 99        => Log(logger, LogLevel.Information, exception, message, arg0);
 100
 101    /// <summary>Runs the LogInformation operation.</summary>
 102    public static void LogInformation<T0, T1>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 arg
 103        => Log(logger, LogLevel.Information, exception, message, arg0, arg1);
 104
 105    /// <summary>Runs the LogInformation operation.</summary>
 106    public static void LogInformation<T0, T1, T2>(this ILogger logger, Exception? exception, string message, T0 arg0, T1
 107        => Log(logger, LogLevel.Information, exception, message, arg0, arg1, arg2);
 108
 109    /// <summary>Runs the LogInformation operation.</summary>
 110    public static void LogInformation<T0, T1, T2, T3>(this ILogger logger, Exception? exception, string message, T0 arg0
 111        => Log(logger, LogLevel.Information, exception, message, arg0, arg1, arg2, arg3);
 112
 113    /// <summary>Runs the LogInformation operation.</summary>
 114    public static void LogInformation<T0, T1, T2, T3, T4>(this ILogger logger, Exception? exception, string message, T0 
 115        => Log(logger, LogLevel.Information, exception, message, arg0, arg1, arg2, arg3, arg4);
 116
 117    /// <summary>Runs the LogInformation operation.</summary>
 118    public static void LogInformation<T0, T1, T2, T3, T4, T5>(this ILogger logger, Exception? exception, string message,
 119        => Log(logger, LogLevel.Information, exception, message, arg0, arg1, arg2, arg3, arg4, arg5);
 120
 121    /// <summary>Runs the LogWarning operation.</summary>
 122    public static void LogWarning(this ILogger logger, string message)
 123        => Log(logger, LogLevel.Warning, exception: null, message);
 124
 125    /// <summary>Runs the LogWarning operation.</summary>
 126    public static void LogWarning<T0>(this ILogger logger, string message, T0 arg0)
 127        => Log(logger, LogLevel.Warning, exception: null, message, arg0);
 128
 129    /// <summary>Runs the LogWarning operation.</summary>
 130    public static void LogWarning<T0, T1>(this ILogger logger, string message, T0 arg0, T1 arg1)
 131        => Log(logger, LogLevel.Warning, exception: null, message, arg0, arg1);
 132
 133    /// <summary>Runs the LogWarning operation.</summary>
 134    public static void LogWarning<T0, T1, T2>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2)
 135        => Log(logger, LogLevel.Warning, exception: null, message, arg0, arg1, arg2);
 136
 137    /// <summary>Runs the LogWarning operation.</summary>
 138    public static void LogWarning<T0, T1, T2, T3>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, T3 arg
 139        => Log(logger, LogLevel.Warning, exception: null, message, arg0, arg1, arg2, arg3);
 140
 141    /// <summary>Runs the LogWarning operation.</summary>
 142    public static void LogWarning<T0, T1, T2, T3, T4>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, T3
 143        => Log(logger, LogLevel.Warning, exception: null, message, arg0, arg1, arg2, arg3, arg4);
 144
 145    /// <summary>Runs the LogWarning operation.</summary>
 146    public static void LogWarning<T0, T1, T2, T3, T4, T5>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2
 147        => Log(logger, LogLevel.Warning, exception: null, message, arg0, arg1, arg2, arg3, arg4, arg5);
 148
 149    /// <summary>Runs the LogWarning operation.</summary>
 150    public static void LogWarning(this ILogger logger, Exception? exception, string message)
 151        => Log(logger, LogLevel.Warning, exception, message);
 152
 153    /// <summary>Runs the LogWarning operation.</summary>
 154    public static void LogWarning<T0>(this ILogger logger, Exception? exception, string message, T0 arg0)
 155        => Log(logger, LogLevel.Warning, exception, message, arg0);
 156
 157    /// <summary>Runs the LogWarning operation.</summary>
 158    public static void LogWarning<T0, T1>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 arg1)
 159        => Log(logger, LogLevel.Warning, exception, message, arg0, arg1);
 160
 161    /// <summary>Runs the LogWarning operation.</summary>
 162    public static void LogWarning<T0, T1, T2>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 arg
 163        => Log(logger, LogLevel.Warning, exception, message, arg0, arg1, arg2);
 164
 165    /// <summary>Runs the LogWarning operation.</summary>
 166    public static void LogWarning<T0, T1, T2, T3>(this ILogger logger, Exception? exception, string message, T0 arg0, T1
 167        => Log(logger, LogLevel.Warning, exception, message, arg0, arg1, arg2, arg3);
 168
 169    /// <summary>Runs the LogWarning operation.</summary>
 170    public static void LogWarning<T0, T1, T2, T3, T4>(this ILogger logger, Exception? exception, string message, T0 arg0
 171        => Log(logger, LogLevel.Warning, exception, message, arg0, arg1, arg2, arg3, arg4);
 172
 173    /// <summary>Runs the LogWarning operation.</summary>
 174    public static void LogWarning<T0, T1, T2, T3, T4, T5>(this ILogger logger, Exception? exception, string message, T0 
 175        => Log(logger, LogLevel.Warning, exception, message, arg0, arg1, arg2, arg3, arg4, arg5);
 176
 177    /// <summary>Runs the LogError operation.</summary>
 178    public static void LogError(this ILogger logger, string message)
 179        => Log(logger, LogLevel.Error, exception: null, message);
 180
 181    /// <summary>Runs the LogError operation.</summary>
 182    public static void LogError<T0>(this ILogger logger, string message, T0 arg0)
 183        => Log(logger, LogLevel.Error, exception: null, message, arg0);
 184
 185    /// <summary>Runs the LogError operation.</summary>
 186    public static void LogError<T0, T1>(this ILogger logger, string message, T0 arg0, T1 arg1)
 187        => Log(logger, LogLevel.Error, exception: null, message, arg0, arg1);
 188
 189    /// <summary>Runs the LogError operation.</summary>
 190    public static void LogError<T0, T1, T2>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2)
 191        => Log(logger, LogLevel.Error, exception: null, message, arg0, arg1, arg2);
 192
 193    /// <summary>Runs the LogError operation.</summary>
 194    public static void LogError<T0, T1, T2, T3>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
 195        => Log(logger, LogLevel.Error, exception: null, message, arg0, arg1, arg2, arg3);
 196
 197    /// <summary>Runs the LogError operation.</summary>
 198    public static void LogError<T0, T1, T2, T3, T4>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, T3 a
 199        => Log(logger, LogLevel.Error, exception: null, message, arg0, arg1, arg2, arg3, arg4);
 200
 201    /// <summary>Runs the LogError operation.</summary>
 202    public static void LogError<T0, T1, T2, T3, T4, T5>(this ILogger logger, string message, T0 arg0, T1 arg1, T2 arg2, 
 203        => Log(logger, LogLevel.Error, exception: null, message, arg0, arg1, arg2, arg3, arg4, arg5);
 204
 205    /// <summary>Runs the LogError operation.</summary>
 206    public static void LogError(this ILogger logger, Exception? exception, string message)
 207        => Log(logger, LogLevel.Error, exception, message);
 208
 209    /// <summary>Runs the LogError operation.</summary>
 210    public static void LogError<T0>(this ILogger logger, Exception? exception, string message, T0 arg0)
 211        => Log(logger, LogLevel.Error, exception, message, arg0);
 212
 213    /// <summary>Runs the LogError operation.</summary>
 214    public static void LogError<T0, T1>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 arg1)
 215        => Log(logger, LogLevel.Error, exception, message, arg0, arg1);
 216
 217    /// <summary>Runs the LogError operation.</summary>
 218    public static void LogError<T0, T1, T2>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 arg1,
 219        => Log(logger, LogLevel.Error, exception, message, arg0, arg1, arg2);
 220
 221    /// <summary>Runs the LogError operation.</summary>
 222    public static void LogError<T0, T1, T2, T3>(this ILogger logger, Exception? exception, string message, T0 arg0, T1 a
 223        => Log(logger, LogLevel.Error, exception, message, arg0, arg1, arg2, arg3);
 224
 225    /// <summary>Runs the LogError operation.</summary>
 226    public static void LogError<T0, T1, T2, T3, T4>(this ILogger logger, Exception? exception, string message, T0 arg0, 
 227        => Log(logger, LogLevel.Error, exception, message, arg0, arg1, arg2, arg3, arg4);
 228
 229    /// <summary>Runs the LogError operation.</summary>
 230    public static void LogError<T0, T1, T2, T3, T4, T5>(this ILogger logger, Exception? exception, string message, T0 ar
 231        => Log(logger, LogLevel.Error, exception, message, arg0, arg1, arg2, arg3, arg4, arg5);
 232
 233    private static void Log(ILogger logger, LogLevel level, Exception? exception, string message)
 234    {
 235        if (!logger.IsEnabled(level))
 236            return;
 237
 238        LogCache.Get(level, message)(logger, exception);
 239    }
 240
 241    private static void Log<T0>(ILogger logger, LogLevel level, Exception? exception, string message, T0 arg0)
 242    {
 243        if (!logger.IsEnabled(level))
 244            return;
 245
 246        LogCache<T0>.Get(level, message)(logger, arg0, exception);
 247    }
 248
 249    private static void Log<T0, T1>(ILogger logger, LogLevel level, Exception? exception, string message, T0 arg0, T1 ar
 250    {
 251        if (!logger.IsEnabled(level))
 252            return;
 253
 254        LogCache<T0, T1>.Get(level, message)(logger, arg0, arg1, exception);
 255    }
 256
 257    private static void Log<T0, T1, T2>(ILogger logger, LogLevel level, Exception? exception, string message, T0 arg0, T
 258    {
 259        if (!logger.IsEnabled(level))
 260            return;
 261
 262        LogCache<T0, T1, T2>.Get(level, message)(logger, arg0, arg1, arg2, exception);
 263    }
 264
 265    private static void Log<T0, T1, T2, T3>(ILogger logger, LogLevel level, Exception? exception, string message, T0 arg
 266    {
 267        if (!logger.IsEnabled(level))
 268            return;
 269
 270        LogCache<T0, T1, T2, T3>.Get(level, message)(logger, arg0, arg1, arg2, arg3, exception);
 271    }
 272
 273    private static void Log<T0, T1, T2, T3, T4>(ILogger logger, LogLevel level, Exception? exception, string message, T0
 274    {
 275        if (!logger.IsEnabled(level))
 276            return;
 277
 278        LogCache<T0, T1, T2, T3, T4>.Get(level, message)(logger, arg0, arg1, arg2, arg3, arg4, exception);
 279    }
 280
 281    private static void Log<T0, T1, T2, T3, T4, T5>(ILogger logger, LogLevel level, Exception? exception, string message
 282    {
 283        if (!logger.IsEnabled(level))
 284            return;
 285
 286        LogCache<T0, T1, T2, T3, T4, T5>.Get(level, message)(logger, arg0, arg1, arg2, arg3, arg4, arg5, exception);
 287    }
 288
 289    private readonly record struct LogKey(LogLevel Level, string Message);
 290
 291    private static class LogCache
 292    {
 293        private static readonly ConcurrentDictionary<LogKey, Action<ILogger, Exception?>> Delegates = new();
 294
 295        /// <summary>Runs the Get operation.</summary>
 296        public static Action<ILogger, Exception?> Get(LogLevel level, string message)
 297            => Delegates.GetOrAdd(
 298                new LogKey(level, message),
 299                static key => LoggerMessage.Define(key.Level, default, key.Message, Options));
 300    }
 301
 302    private static class LogCache<T0>
 303    {
 304        private static readonly ConcurrentDictionary<LogKey, Action<ILogger, T0, Exception?>> Delegates = new();
 305
 306        /// <summary>Runs the Get operation.</summary>
 307        public static Action<ILogger, T0, Exception?> Get(LogLevel level, string message)
 308            => Delegates.GetOrAdd(
 309                new LogKey(level, message),
 310                static key => LoggerMessage.Define<T0>(key.Level, default, key.Message, Options));
 311    }
 312
 313    private static class LogCache<T0, T1>
 314    {
 315        private static readonly ConcurrentDictionary<LogKey, Action<ILogger, T0, T1, Exception?>> Delegates = new();
 316
 317        /// <summary>Runs the Get operation.</summary>
 318        public static Action<ILogger, T0, T1, Exception?> Get(LogLevel level, string message)
 319            => Delegates.GetOrAdd(
 320                new LogKey(level, message),
 321                static key => LoggerMessage.Define<T0, T1>(key.Level, default, key.Message, Options));
 322    }
 323
 324    private static class LogCache<T0, T1, T2>
 325    {
 3326        private static readonly ConcurrentDictionary<LogKey, Action<ILogger, T0, T1, T2, Exception?>> Delegates = new();
 327
 328        /// <summary>Runs the Get operation.</summary>
 329        public static Action<ILogger, T0, T1, T2, Exception?> Get(LogLevel level, string message)
 3330            => Delegates.GetOrAdd(
 3331                new LogKey(level, message),
 332                static key => LoggerMessage.Define<T0, T1, T2>(key.Level, default, key.Message, Options));
 333    }
 334
 335    private static class LogCache<T0, T1, T2, T3>
 336    {
 337        private static readonly ConcurrentDictionary<LogKey, Action<ILogger, T0, T1, T2, T3, Exception?>> Delegates = ne
 338
 339        /// <summary>Runs the Get operation.</summary>
 340        public static Action<ILogger, T0, T1, T2, T3, Exception?> Get(LogLevel level, string message)
 341            => Delegates.GetOrAdd(
 342                new LogKey(level, message),
 343                static key => LoggerMessage.Define<T0, T1, T2, T3>(key.Level, default, key.Message, Options));
 344    }
 345
 346    private static class LogCache<T0, T1, T2, T3, T4>
 347    {
 348        private static readonly ConcurrentDictionary<LogKey, Action<ILogger, T0, T1, T2, T3, T4, Exception?>> Delegates 
 349
 350        /// <summary>Runs the Get operation.</summary>
 351        public static Action<ILogger, T0, T1, T2, T3, T4, Exception?> Get(LogLevel level, string message)
 352            => Delegates.GetOrAdd(
 353                new LogKey(level, message),
 354                static key => LoggerMessage.Define<T0, T1, T2, T3, T4>(key.Level, default, key.Message, Options));
 355    }
 356
 357    private static class LogCache<T0, T1, T2, T3, T4, T5>
 358    {
 359        private static readonly ConcurrentDictionary<LogKey, Action<ILogger, T0, T1, T2, T3, T4, T5, Exception?>> Delega
 360
 361        /// <summary>Runs the Get operation.</summary>
 362        public static Action<ILogger, T0, T1, T2, T3, T4, T5, Exception?> Get(LogLevel level, string message)
 363            => Delegates.GetOrAdd(
 364                new LogKey(level, message),
 365                static key => LoggerMessage.Define<T0, T1, T2, T3, T4, T5>(key.Level, default, key.Message, Options));
 366    }
 367}