Skip to content

chore: Logging improved message formatting #869

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

Merged

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented May 6, 2025

Please provide the issue number

Issue number: #868

Summary

Changes

This pull request refactors logging to improve message template formatting and parameter handling. It also removes extra keys extensions code and ensures consistent usage of logging methods.

Refactoring for Logging Methods and Message Templates:

  • Updated multiple test cases (LogFormatterTest.cs, LogFormattingTests.cs, and PowertoolsLoggerTest.cs) to use consistent parameter ordering in LogInformation, LogDebug, LogTrace, and other logging methods. This ensures that message templates and parameters are handled uniformly. [1] [2] [3] [4]

  • Enhanced test cases to verify message template formatting and the inclusion of parameters in log outputs. Added a new test TestMessageTemplateFormatting in LogFormattingTests.cs to validate single and multiple parameter scenarios.

Improvements to Extra Keys Handling:

  • Modified tests in PowertoolsLoggerTest.cs to ensure proper handling of extra keys (scopeKeys) as part of the message template. This change standardizes the way extra keys are appended to log messages. [1] [2] [3]

Dependency Updates:

  • Added Microsoft.Extensions.Logging to LogFormatterTest.cs to support the improved logging functionality.

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.

@boring-cyborg boring-cyborg bot added area/logging Core logging utility tests labels May 6, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 6, 2025
Copy link

sonarqubecloud bot commented May 6, 2025

Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.57%. Comparing base (7357a5b) to head (5da8fbb).
Report is 31 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #869      +/-   ##
===========================================
+ Coverage    75.75%   76.57%   +0.82%     
===========================================
  Files          249      248       -1     
  Lines         9875     9696     -179     
  Branches      1073     1071       -2     
===========================================
- Hits          7481     7425      -56     
+ Misses        2056     1933     -123     
  Partials       338      338              

☔ 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.

@hjgraca hjgraca changed the title refactor logging methods for improved message formatting chore: Logging improved message formatting May 6, 2025
@hjgraca hjgraca requested a review from leandrodamascena May 6, 2025 10:22
@github-actions github-actions bot added the internal Maintenance changes label May 6, 2025
@hjgraca hjgraca merged commit 4c8cec9 into aws-powertools:develop May 6, 2025
11 checks passed
@hjgraca hjgraca deleted the chore/logger-formatting-update branch May 6, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging Core logging utility internal Maintenance changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants