-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contributes to #24055 Contributes to #32087 * This updates most of the repo to use LoggerMessageAttributes. MvcCoreLoggerExtensions is the only standout but it is fairly involved since it mixes logging from several types, re-uses logger ids etc
- Loading branch information
Showing
12 changed files
with
99 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable disable | ||
|
||
namespace Microsoft.Extensions.Logging; | ||
|
||
internal static class LoggingExtensions | ||
internal static partial class LoggingExtensions | ||
{ | ||
private static readonly Action<ILogger, Exception> _invalidExpirationTime; | ||
private static readonly Action<ILogger, Exception> _userIdsNotEquals; | ||
private static readonly Action<ILogger, string, string, Exception> _purposeNotEquals; | ||
private static readonly Action<ILogger, Exception> _unexpectedEndOfInput; | ||
private static readonly Action<ILogger, Exception> _securityStampNotEquals; | ||
private static readonly Action<ILogger, Exception> _securityStampIsNotEmpty; | ||
private static readonly Action<ILogger, Exception> _unhandledException; | ||
|
||
static LoggingExtensions() | ||
{ | ||
_invalidExpirationTime = LoggerMessage.Define( | ||
eventId: new EventId(0, "InvalidExpirationTime"), | ||
logLevel: LogLevel.Debug, | ||
formatString: "ValidateAsync failed: the expiration time is invalid."); | ||
|
||
_userIdsNotEquals = LoggerMessage.Define( | ||
eventId: new EventId(1, "UserIdsNotEquals"), | ||
logLevel: LogLevel.Debug, | ||
formatString: "ValidateAsync failed: did not find expected UserId."); | ||
|
||
_purposeNotEquals = LoggerMessage.Define<string, string>( | ||
eventId: new EventId(2, "PurposeNotEquals"), | ||
logLevel: LogLevel.Debug, | ||
formatString: "ValidateAsync failed: did not find expected purpose. '{ActualPurpose}' does not match the expected purpose '{ExpectedPurpose}'."); | ||
|
||
_unexpectedEndOfInput = LoggerMessage.Define( | ||
eventId: new EventId(3, "UnexpectedEndOfInput"), | ||
logLevel: LogLevel.Debug, | ||
formatString: "ValidateAsync failed: unexpected end of input."); | ||
|
||
_securityStampNotEquals = LoggerMessage.Define( | ||
eventId: new EventId(4, "SecurityStampNotEquals"), | ||
logLevel: LogLevel.Debug, | ||
formatString: "ValidateAsync failed: did not find expected security stamp."); | ||
|
||
_securityStampIsNotEmpty = LoggerMessage.Define( | ||
eventId: new EventId(5, "SecurityStampIsNotEmpty"), | ||
logLevel: LogLevel.Debug, | ||
formatString: "ValidateAsync failed: the expected stamp is not empty."); | ||
|
||
_unhandledException = LoggerMessage.Define( | ||
eventId: new EventId(6, "UnhandledException"), | ||
logLevel: LogLevel.Debug, | ||
formatString: "ValidateAsync failed: unhandled exception was thrown."); | ||
} | ||
|
||
public static void InvalidExpirationTime(this ILogger logger) | ||
{ | ||
_invalidExpirationTime(logger, null); | ||
} | ||
[LoggerMessage(0, LogLevel.Debug, "ValidateAsync failed: the expiration time is invalid.", EventName = "InvalidExpirationTime")] | ||
public static partial void InvalidExpirationTime(this ILogger logger); | ||
|
||
public static void UserIdsNotEquals(this ILogger logger) | ||
{ | ||
_userIdsNotEquals(logger, null); | ||
} | ||
[LoggerMessage(1, LogLevel.Debug, "ValidateAsync failed: did not find expected UserId.", EventName = "UserIdsNotEquals")] | ||
public static partial void UserIdsNotEquals(this ILogger logger); | ||
|
||
public static void PurposeNotEquals(this ILogger logger, string actualPurpose, string expectedPurpose) | ||
{ | ||
_purposeNotEquals(logger, actualPurpose, expectedPurpose, null); | ||
} | ||
[LoggerMessage(2, LogLevel.Debug, "ValidateAsync failed: did not find expected purpose. '{ActualPurpose}' does not match the expected purpose '{ExpectedPurpose}'.", EventName = "PurposeNotEquals")] | ||
public static partial void PurposeNotEquals(this ILogger logger, string actualPurpose, string expectedPurpose); | ||
|
||
public static void UnexpectedEndOfInput(this ILogger logger) | ||
{ | ||
_unexpectedEndOfInput(logger, null); | ||
} | ||
[LoggerMessage(3, LogLevel.Debug, "ValidateAsync failed: unexpected end of input.", EventName = "UnexpectedEndOfInput")] | ||
public static partial void UnexpectedEndOfInput(this ILogger logger); | ||
|
||
public static void SecurityStampNotEquals(this ILogger logger) | ||
{ | ||
_securityStampNotEquals(logger, null); | ||
} | ||
[LoggerMessage(4, LogLevel.Debug, "ValidateAsync failed: did not find expected security stamp.", EventName = "SecurityStampNotEquals")] | ||
public static partial void SecurityStampNotEquals(this ILogger logger); | ||
|
||
public static void SecurityStampIsNotEmpty(this ILogger logger) | ||
{ | ||
_securityStampIsNotEmpty(logger, null); | ||
} | ||
[LoggerMessage(5, LogLevel.Debug, "ValidateAsync failed: the expected stamp is not empty.", EventName = "SecurityStampIsNotEmpty")] | ||
public static partial void SecurityStampIsNotEmpty(this ILogger logger); | ||
|
||
public static void UnhandledException(this ILogger logger) | ||
{ | ||
_unhandledException(logger, null); | ||
} | ||
[LoggerMessage(6, LogLevel.Debug, "ValidateAsync failed: unhandled exception was thrown.", EventName = "UnhandledException")] | ||
public static partial void UnhandledException(this ILogger logger); | ||
} |
26 changes: 0 additions & 26 deletions
26
src/Localization/Localization/src/Internal/ResourceManagerStringLocalizerLoggerExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.