|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements.
|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
4 |
| -#nullable disable |
5 |
| - |
6 | 4 | namespace Microsoft.Extensions.Logging;
|
7 | 5 |
|
8 |
| -internal static class LoggingExtensions |
| 6 | +internal static partial class LoggingExtensions |
9 | 7 | {
|
10 |
| - private static readonly Action<ILogger, Exception> _invalidExpirationTime; |
11 |
| - private static readonly Action<ILogger, Exception> _userIdsNotEquals; |
12 |
| - private static readonly Action<ILogger, string, string, Exception> _purposeNotEquals; |
13 |
| - private static readonly Action<ILogger, Exception> _unexpectedEndOfInput; |
14 |
| - private static readonly Action<ILogger, Exception> _securityStampNotEquals; |
15 |
| - private static readonly Action<ILogger, Exception> _securityStampIsNotEmpty; |
16 |
| - private static readonly Action<ILogger, Exception> _unhandledException; |
17 |
| - |
18 |
| - static LoggingExtensions() |
19 |
| - { |
20 |
| - _invalidExpirationTime = LoggerMessage.Define( |
21 |
| - eventId: new EventId(0, "InvalidExpirationTime"), |
22 |
| - logLevel: LogLevel.Debug, |
23 |
| - formatString: "ValidateAsync failed: the expiration time is invalid."); |
24 |
| - |
25 |
| - _userIdsNotEquals = LoggerMessage.Define( |
26 |
| - eventId: new EventId(1, "UserIdsNotEquals"), |
27 |
| - logLevel: LogLevel.Debug, |
28 |
| - formatString: "ValidateAsync failed: did not find expected UserId."); |
29 |
| - |
30 |
| - _purposeNotEquals = LoggerMessage.Define<string, string>( |
31 |
| - eventId: new EventId(2, "PurposeNotEquals"), |
32 |
| - logLevel: LogLevel.Debug, |
33 |
| - formatString: "ValidateAsync failed: did not find expected purpose. '{ActualPurpose}' does not match the expected purpose '{ExpectedPurpose}'."); |
34 |
| - |
35 |
| - _unexpectedEndOfInput = LoggerMessage.Define( |
36 |
| - eventId: new EventId(3, "UnexpectedEndOfInput"), |
37 |
| - logLevel: LogLevel.Debug, |
38 |
| - formatString: "ValidateAsync failed: unexpected end of input."); |
39 |
| - |
40 |
| - _securityStampNotEquals = LoggerMessage.Define( |
41 |
| - eventId: new EventId(4, "SecurityStampNotEquals"), |
42 |
| - logLevel: LogLevel.Debug, |
43 |
| - formatString: "ValidateAsync failed: did not find expected security stamp."); |
44 |
| - |
45 |
| - _securityStampIsNotEmpty = LoggerMessage.Define( |
46 |
| - eventId: new EventId(5, "SecurityStampIsNotEmpty"), |
47 |
| - logLevel: LogLevel.Debug, |
48 |
| - formatString: "ValidateAsync failed: the expected stamp is not empty."); |
49 |
| - |
50 |
| - _unhandledException = LoggerMessage.Define( |
51 |
| - eventId: new EventId(6, "UnhandledException"), |
52 |
| - logLevel: LogLevel.Debug, |
53 |
| - formatString: "ValidateAsync failed: unhandled exception was thrown."); |
54 |
| - } |
55 |
| - |
56 |
| - public static void InvalidExpirationTime(this ILogger logger) |
57 |
| - { |
58 |
| - _invalidExpirationTime(logger, null); |
59 |
| - } |
| 8 | + [LoggerMessage(0, LogLevel.Debug, "ValidateAsync failed: the expiration time is invalid.", EventName = "InvalidExpirationTime")] |
| 9 | + public static partial void InvalidExpirationTime(this ILogger logger); |
60 | 10 |
|
61 |
| - public static void UserIdsNotEquals(this ILogger logger) |
62 |
| - { |
63 |
| - _userIdsNotEquals(logger, null); |
64 |
| - } |
| 11 | + [LoggerMessage(1, LogLevel.Debug, "ValidateAsync failed: did not find expected UserId.", EventName = "UserIdsNotEquals")] |
| 12 | + public static partial void UserIdsNotEquals(this ILogger logger); |
65 | 13 |
|
66 |
| - public static void PurposeNotEquals(this ILogger logger, string actualPurpose, string expectedPurpose) |
67 |
| - { |
68 |
| - _purposeNotEquals(logger, actualPurpose, expectedPurpose, null); |
69 |
| - } |
| 14 | + [LoggerMessage(2, LogLevel.Debug, "ValidateAsync failed: did not find expected purpose. '{ActualPurpose}' does not match the expected purpose '{ExpectedPurpose}'.", EventName = "PurposeNotEquals")] |
| 15 | + public static partial void PurposeNotEquals(this ILogger logger, string actualPurpose, string expectedPurpose); |
70 | 16 |
|
71 |
| - public static void UnexpectedEndOfInput(this ILogger logger) |
72 |
| - { |
73 |
| - _unexpectedEndOfInput(logger, null); |
74 |
| - } |
| 17 | + [LoggerMessage(3, LogLevel.Debug, "ValidateAsync failed: unexpected end of input.", EventName = "UnexpectedEndOfInput")] |
| 18 | + public static partial void UnexpectedEndOfInput(this ILogger logger); |
75 | 19 |
|
76 |
| - public static void SecurityStampNotEquals(this ILogger logger) |
77 |
| - { |
78 |
| - _securityStampNotEquals(logger, null); |
79 |
| - } |
| 20 | + [LoggerMessage(4, LogLevel.Debug, "ValidateAsync failed: did not find expected security stamp.", EventName = "SecurityStampNotEquals")] |
| 21 | + public static partial void SecurityStampNotEquals(this ILogger logger); |
80 | 22 |
|
81 |
| - public static void SecurityStampIsNotEmpty(this ILogger logger) |
82 |
| - { |
83 |
| - _securityStampIsNotEmpty(logger, null); |
84 |
| - } |
| 23 | + [LoggerMessage(5, LogLevel.Debug, "ValidateAsync failed: the expected stamp is not empty.", EventName = "SecurityStampIsNotEmpty")] |
| 24 | + public static partial void SecurityStampIsNotEmpty(this ILogger logger); |
85 | 25 |
|
86 |
| - public static void UnhandledException(this ILogger logger) |
87 |
| - { |
88 |
| - _unhandledException(logger, null); |
89 |
| - } |
| 26 | + [LoggerMessage(6, LogLevel.Debug, "ValidateAsync failed: unhandled exception was thrown.", EventName = "UnhandledException")] |
| 27 | + public static partial void UnhandledException(this ILogger logger); |
90 | 28 | }
|
0 commit comments