|
2 | 2 |
|
3 | 3 | namespace Bunit.Extensions.WaitForHelpers; |
4 | 4 |
|
5 | | -internal static class WaitForHelperLoggerExtensions |
| 5 | +internal static partial class WaitForHelperLoggerExtensions |
6 | 6 | { |
7 | | - private static readonly Action<ILogger, int, Exception?> CheckingWaitCondition |
8 | | - = LoggerMessage.Define<int>(LogLevel.Debug, new EventId(1, "CheckingWaitCondition"), "Checking the wait condition for component {Id}."); |
9 | | - |
10 | | - private static readonly Action<ILogger, int, Exception?> CheckCompleted |
11 | | - = LoggerMessage.Define<int>(LogLevel.Debug, new EventId(2, "CheckCompleted"), "The check completed successfully for component {Id}."); |
12 | | - |
13 | | - private static readonly Action<ILogger, int, Exception?> CheckFailed |
14 | | - = LoggerMessage.Define<int>(LogLevel.Debug, new EventId(3, "CheckFailed"), "The check failed for component {Id}."); |
15 | | - |
16 | | - private static readonly Action<ILogger, int, Exception> CheckThrow |
17 | | - = LoggerMessage.Define<int>(LogLevel.Debug, new EventId(4, "CheckThrow"), "The checker for component {Id} throw an exception."); |
18 | | - |
19 | | - private static readonly Action<ILogger, int, Exception?> WaiterTimedOut |
20 | | - = LoggerMessage.Define<int>(LogLevel.Debug, new EventId(10, "WaiterTimedOut"), "The waiter for component {Id} timed out."); |
21 | | - |
22 | | - private static readonly Action<ILogger, int, Exception?> WaiterDisposed |
23 | | - = LoggerMessage.Define<int>(LogLevel.Debug, new EventId(20, "WaiterDisposed"), "The waiter for component {Id} disposed."); |
24 | | - |
25 | | - internal static void LogCheckingWaitCondition(this ILogger logger, int componentId) |
26 | | - { |
27 | | - if (logger.IsEnabled(LogLevel.Debug)) |
28 | | - { |
29 | | - CheckingWaitCondition(logger, componentId, null); |
30 | | - } |
31 | | - } |
32 | | - |
33 | | - internal static void LogCheckCompleted(this ILogger logger, int componentId) |
34 | | - { |
35 | | - if (logger.IsEnabled(LogLevel.Debug)) |
36 | | - { |
37 | | - CheckCompleted(logger, componentId, null); |
38 | | - } |
39 | | - } |
40 | | - |
41 | | - internal static void LogCheckFailed(this ILogger logger, int componentId) |
42 | | - { |
43 | | - if (logger.IsEnabled(LogLevel.Debug)) |
44 | | - { |
45 | | - CheckFailed(logger, componentId, null); |
46 | | - } |
47 | | - } |
48 | | - |
49 | | - internal static void LogCheckThrow(this ILogger logger, int componentId, Exception exception) |
50 | | - { |
51 | | - if (logger.IsEnabled(LogLevel.Debug)) |
52 | | - { |
53 | | - CheckThrow(logger, componentId, exception); |
54 | | - } |
55 | | - } |
56 | | - |
57 | | - internal static void LogWaiterTimedOut(this ILogger logger, int componentId) |
58 | | - { |
59 | | - if (logger.IsEnabled(LogLevel.Debug)) |
60 | | - { |
61 | | - WaiterTimedOut(logger, componentId, null); |
62 | | - } |
63 | | - } |
64 | | - |
65 | | - internal static void LogWaiterDisposed(this ILogger logger, int componentId) |
66 | | - { |
67 | | - if (logger.IsEnabled(LogLevel.Debug)) |
68 | | - { |
69 | | - WaiterDisposed(logger, componentId, null); |
70 | | - } |
71 | | - } |
| 7 | + [LoggerMessage( |
| 8 | + EventId = 1, |
| 9 | + EventName = "CheckingWaitCondition", |
| 10 | + Level = LogLevel.Debug, |
| 11 | + Message = "Checking the wait condition for component {ComponentId}.")] |
| 12 | + |
| 13 | + internal static partial void LogCheckingWaitCondition(this ILogger logger, int componentId); |
| 14 | + |
| 15 | + [LoggerMessage( |
| 16 | + EventId = 2, |
| 17 | + EventName = "CheckCompleted", |
| 18 | + Level = LogLevel.Debug, |
| 19 | + Message = "The check completed successfully for component {ComponentId}.")] |
| 20 | + internal static partial void LogCheckCompleted(this ILogger logger, int componentId); |
| 21 | + |
| 22 | + [LoggerMessage( |
| 23 | + EventId = 3, |
| 24 | + EventName = "CheckFailed", |
| 25 | + Level = LogLevel.Debug, |
| 26 | + Message = "The check failed for component {ComponentId}.")] |
| 27 | + internal static partial void LogCheckFailed(this ILogger logger, int componentId); |
| 28 | + |
| 29 | + [LoggerMessage( |
| 30 | + EventId = 4, |
| 31 | + EventName = "CheckThrow", |
| 32 | + Level = LogLevel.Debug, |
| 33 | + Message = "The checker for component {ComponentId} throw an exception.")] |
| 34 | + internal static partial void LogCheckThrow(this ILogger logger, int componentId, Exception exception); |
| 35 | + |
| 36 | + [LoggerMessage( |
| 37 | + EventId = 10, |
| 38 | + EventName = "WaiterTimedOut", |
| 39 | + Level = LogLevel.Debug, |
| 40 | + Message = "The waiter for component {ComponentId} timed out.")] |
| 41 | + internal static partial void LogWaiterTimedOut(this ILogger logger, int componentId); |
| 42 | + |
| 43 | + [LoggerMessage( |
| 44 | + EventId = 20, |
| 45 | + EventName = "WaiterDisposed", |
| 46 | + Level = LogLevel.Debug, |
| 47 | + Message = "The waiter for component {ComponentId} disposed.")] |
| 48 | + internal static partial void LogWaiterDisposed(this ILogger logger, int componentId); |
72 | 49 | } |
0 commit comments