Skip to content

feat(logging): add Enabled property to LogBuffering configuration#1125

Open
hjgraca wants to merge 4 commits intodevelopfrom
chore/log-buffering-api
Open

feat(logging): add Enabled property to LogBuffering configuration#1125
hjgraca wants to merge 4 commits intodevelopfrom
chore/log-buffering-api

Conversation

@hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Jan 29, 2026

Please provide the issue number

Issue number: #1042

Summary

Changes

  • Add Enabled property to LogBufferingOptions to explicitly control log buffering activation
  • Update PowertoolsLoggerConfiguration to expose LogBuffering as a configurable property
  • Refactor log buffering initialization to check Enabled flag before activating buffer
  • Update documentation to reflect new configuration pattern using property assignment instead of constructor
  • Update all test cases to use new LogBuffering.Enabled pattern
  • Add Enabled parameter to buffering configuration table in documentation

User experience

Please share what the user experience looks like before and after this change

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

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.

closes #1042

- Add `Enabled` property to `LogBufferingOptions` to explicitly control log buffering activation
- Update `PowertoolsLoggerConfiguration` to expose `LogBuffering` as a configurable property
- Refactor log buffering initialization to check `Enabled` flag before activating buffer
- Update documentation to reflect new configuration pattern using property assignment instead of constructor
- Simplify buffering setup by allowing incremental property configuration
- Update all test cases to use new `LogBuffering.Enabled` pattern
- Add `Enabled` parameter to buffering configuration table in documentation
- Improve clarity of log buffering setup examples in ASP.NET and core logging guides
@boring-cyborg boring-cyborg bot added area/logging Core logging utility documentation Improvements or additions to documentation tests labels Jan 29, 2026
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 29, 2026
@github-actions github-actions bot added the feature New features or minor changes label Jan 29, 2026
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.26%. Comparing base (989220b) to head (d233109).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
...ambda.Powertools.Logging/Internal/LoggingAspect.cs 0.00% 0 Missing and 1 partial ⚠️
...da.Powertools.Logging/Internal/PowertoolsLogger.cs 75.00% 0 Missing and 1 partial ⚠️
...ools.Logging/PowertoolsLoggingBuilderExtensions.cs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1125      +/-   ##
===========================================
+ Coverage    79.23%   79.26%   +0.02%     
===========================================
  Files          299      299              
  Lines        12441    12455      +14     
  Branches      1490     1490              
===========================================
+ Hits          9858     9872      +14     
  Misses        2128     2128              
  Partials       455      455              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings February 4, 2026 09:21
@pull-request-size pull-request-size bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the log buffering configuration API to make it more intuitive by adding an Enabled property to LogBufferingOptions and initializing it by default in PowertoolsLoggerConfiguration. This addresses issue #1042 where users found the configuration pattern confusing because log buffering was only activated when the LogBuffering property was not null, requiring users to instantiate an empty options object even when using defaults.

Changes:

  • Added Enabled boolean property to LogBufferingOptions to explicitly control buffering activation
  • Initialized LogBuffering property with a default instance in PowertoolsLoggerConfiguration to enable property assignment pattern
  • Updated buffering activation logic to check LogBuffering?.Enabled == true instead of null check
  • Refactored all tests and documentation to use the new pattern: config.LogBuffering.Enabled = true

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
LogBufferingOptions.cs Added Enabled property with documentation and examples
PowertoolsLoggerConfiguration.cs Initialized LogBuffering property with default instance and updated documentation
PowertoolsLoggingBuilderExtensions.cs Updated buffering registration check to use Enabled flag
PowertoolsLoggerBuilder.cs Updated WithLogBuffering to set Enabled = true instead of creating new instance
Internal/PowertoolsLogger.cs Added Enabled check to log level filtering logic
Internal/LoggingAspect.cs Updated buffering flag initialization to check Enabled property
PowertoolsLoggerBuilderTests.cs Added comprehensive tests for enabled/disabled/null buffering scenarios
Various test files Updated all existing tests to use new property assignment pattern
BasePersistenceStoreTests.cs Added tests for idempotency persistence (appears unrelated to logging changes)
Documentation files Updated all examples to demonstrate new configuration pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hjgraca and others added 2 commits February 4, 2026 09:32
…nfiguration.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/logging Core logging utility documentation Improvements or additions to documentation feature New features or minor changes size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage of LogBuffering is confusing

1 participant