-
Notifications
You must be signed in to change notification settings - Fork 29
chore: Add automatic registration of standard logging services and ILogger #938
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
chore: Add automatic registration of standard logging services and ILogger #938
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #938 +/- ##
===========================================
+ Coverage 77.31% 77.38% +0.06%
===========================================
Files 271 271
Lines 10864 10870 +6
Branches 1280 1281 +1
===========================================
+ Hits 8400 8412 +12
+ Misses 2046 2041 -5
+ Partials 418 417 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hi @hjgraca! I tried adding the temporary fix you mentioned here and it had a weird side effect. It looks like log messages are being output twice, once as a standard log message and once as a structured log message (as expected): For this PR, I think the logging provider that you added on 86 might need to be removed later to avoid this issue. It's also possible that the temp fix I tried works differently and as such, this is a non-issue 😄. |
Ah yes, it needs to clear providers, good catch
|
To prevent multiple logger providers the user can do it manually builder.Logging.ClearProviders(); or with the new method override builder.Logging.AddPowertoolsLogger(config =>
{
config.Service = "TestService";
config.LoggerOutputCase = LoggerOutputCase.PascalCase;
}, clearExistingProviders: true); |
I ran a test with this, and it works. Thank you! |
…olsLoggingBuilderExtensions
|
Issue number: #937
Summary
Changes
This pull request enhances the
AddPowertoolsLogger
method inAWS.Lambda.Powertools.Logging
to improve service registration and logging functionality. The most notable changes include adding standard logging services and automatically registering theILogger
interface.Improvements to service registration:
libraries/src/AWS.Lambda.Powertools.Logging/PowertoolsLoggingBuilderExtensions.cs
: Addedbuilder.Services.AddLogging()
to register standard logging services.Enhancements to logging functionality:
libraries/src/AWS.Lambda.Powertools.Logging/PowertoolsLoggingBuilderExtensions.cs
: Automatically registered theILogger
interface by adding a singleton service that retrieves and creates aPowertoolsLogger
instance from theILoggerFactory
.User experience
Checklist
Please leave checklist items unchecked if they do not apply to your change.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.