-
Notifications
You must be signed in to change notification settings - Fork 322
PoC | Remove Abstractions dependency on Logging #4024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8448030
8fc206e
a053532
4bbf86b
4af8e8a
facb959
24879bb
67a2982
c3d3f38
bc76a5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| namespace Microsoft.Data.SqlClient.Extensions.Abstractions.Logging; | ||
|
|
||
| /// <summary> | ||
| /// The names of logging categories written to by Microsoft.Data.SqlClient. | ||
| /// </summary> | ||
| public static class CategoryNames | ||
| { | ||
| /// <summary> | ||
| /// Captures basic application flow trace events. | ||
| /// </summary> | ||
| public const string Trace = "Microsoft.Data.SqlClient.Logging.Trace"; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Microsoft.Data.SqlClient.Extensions.Abstractions.Logging; | ||
|
|
||
| internal static partial class LogMessages | ||
| { | ||
| [LoggerMessage(EventId = 1, EventName = nameof(AssemblyNotFound), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | MDS assembly={{assemblyName}} not found; Get/SetProvider() will not function.")] | ||
| public static partial void AssemblyNotFound(this ILogger logger, string assemblyName); | ||
|
|
||
| [LoggerMessage(EventId = 2, EventName = nameof(AuthManagerClassNotFound), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | MDS auth manager class {{className}} not found; Get/SetProvider() will not function.")] | ||
| public static partial void AuthManagerClassNotFound(this ILogger logger, string className); | ||
|
|
||
| [LoggerMessage(EventId = 3, EventName = nameof(GetProviderMethodNotFound), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | MDS GetProvider() method not found; Get/SetProvider() will not function.")] | ||
| public static partial void GetProviderMethodNotFound(this ILogger logger); | ||
|
|
||
| [LoggerMessage(EventId = 4, EventName = nameof(SetProviderMethodNotFound), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | MDS SetProvider() method not found; Get/SetProvider() will not function.")] | ||
| public static partial void SetProviderMethodNotFound(this ILogger logger); | ||
|
|
||
| [LoggerMessage(EventId = 5, EventName = nameof(AssemblyNotFoundOrUsable), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | MDS assembly={{assemblyName}} not found or not usable; Get/SetProvider() will not function: {{exceptionString}}")] | ||
| public static partial void AssemblyNotFoundOrUsable(this ILogger logger, string assemblyName, string exceptionString); | ||
|
|
||
| [LoggerMessage(EventId = 6, EventName = nameof(GetProviderInvocationFailed), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | GetProvider() invocation failed: {{exceptionType}}: {{exceptionString}}")] | ||
| public static partial void GetProviderInvocationFailed(this ILogger logger, string exceptionType, string exceptionString); | ||
|
|
||
| [LoggerMessage(EventId = 7, EventName = nameof(SetProviderInvocationReturnedNull), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | SetProvider() invocation returned null; translating to false.")] | ||
| public static partial void SetProviderInvocationReturnedNull(this ILogger logger); | ||
|
|
||
| [LoggerMessage(EventId = 8, EventName = nameof(SetProviderInvocationFailed), | ||
| Level = LogLevel.Warning, | ||
| Message = $"SqlAuthenticationProvider.Internal | SetProvider() invocation failed: {{exceptionType}}: {{exceptionString}}")] | ||
| public static partial void SetProviderInvocationFailed(this ILogger logger, string exceptionType, string exceptionString); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using System.Runtime.CompilerServices; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Microsoft.Data.SqlClient.Extensions.Abstractions.Logging; | ||
|
Comment on lines
+1
to
+4
|
||
|
|
||
| /// <summary> | ||
| /// <see cref="ILogger"/> extension methods for use by Microsoft.Data.SqlClient. | ||
| /// </summary> | ||
| public static class LoggerExtensions | ||
| { | ||
| /// <summary> | ||
| /// Begins a logical operation scope, defined by the class name, calling member and a scope identifier. | ||
| /// </summary> | ||
| /// <param name="logger"><see cref="ILogger"/> instance to use to begin the scope.</param> | ||
| /// <param name="className">Class containing the calling member.</param> | ||
| /// <param name="memberName">Name of the calling member.</param> | ||
| /// <returns>An <see cref="IDisposable"/> that ends the logical operation scope on dispose.</returns> | ||
| public static IDisposable? BeginMemberScope(this ILogger logger, string className, [CallerMemberName] string memberName = "") => | ||
| logger.BeginScope($"{className}.{memberName} | INFO | SCOPE | Entering Scope {{0}}"); | ||
| } | ||
|
Comment on lines
+9
to
+20
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new source file is missing the standard .NET Foundation/MIT license header that appears at the top of other files in the repo. Please add the repo’s standard header before the first using directive.