Skip to content
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

fix(logger): ensure state is cleared for custom formatters #1072

Merged

Conversation

heitorlessa
Copy link
Contributor

Issue #, if available: #1042

Description of changes:

This ensures custom logger formatters receive Lambda context keys and their state can be cleared upon each invocation when using clear_state. This PR also takes into account those using log_record_order with custom formatters, if the state is ever cleared.

The reason we use an abstractmethod is to ensure all functionalities (as docs suggested) will work for the ~1% of customers creating highly customized loggers that can work in more than Lambda environments. We initially thought in having warnings but given this is a bug behavior and the extreme edge case, it makes it worthwhile to enforce it early and improve documentation on use cases for LambdaPowertoolsFormatter (common, no change required) vs BasePowertoolsFormatter (edge case).

Checklist

Breaking change checklist

RFC issue #:

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

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 8, 2022
@github-actions github-actions bot added the bug Something isn't working label Mar 8, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2022

Codecov Report

Merging #1072 (7c44ba8) into develop (22f8b9a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 7c44ba8 differs from pull request most recent head 124a19b. Consider uploading reports for the commit 124a19b to get more accurate results

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1072   +/-   ##
========================================
  Coverage    99.96%   99.96%           
========================================
  Files          119      119           
  Lines         5365     5373    +8     
  Branches       612      613    +1     
========================================
+ Hits          5363     5371    +8     
  Partials         2        2           
Impacted Files Coverage Δ
aws_lambda_powertools/logging/formatter.py 100.00% <100.00%> (ø)
aws_lambda_powertools/logging/logger.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22f8b9a...124a19b. Read the comment docs.

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 9, 2022
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Mar 9, 2022
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 9, 2022
@heitorlessa heitorlessa changed the title fix(logger): ensure state is cleared for all formatters fix(logger): ensure state is cleared for custom formatters Mar 9, 2022
@heitorlessa heitorlessa merged commit c337ef9 into aws-powertools:develop Mar 9, 2022
@heitorlessa heitorlessa deleted the fix/logger-custom-formatter branch March 9, 2022 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants