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

feat(logger): add option to clear state per invocation #467

Merged

Conversation

heitorlessa
Copy link
Contributor

@heitorlessa heitorlessa commented Jun 8, 2021

Issue #, if available:

Description of changes:

Checklist

UX

from aws_lambda_powertools import Logger

logger = Logger(service="payment")

@logger.inject_lambda_context(clear_state=True)
def handler(event, context):
    if event.get("special_key"):
        # Should only be available in the first request log
        # as the second request doesn't contain `special_key`
        logger.append_keys(debugging_key="value")

    logger.info("Collecting payment")

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.

@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation tests labels Jun 8, 2021
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 8, 2021
@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2021

Codecov Report

Merging #467 (a691676) into develop (086be96) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #467   +/-   ##
========================================
  Coverage    99.90%   99.90%           
========================================
  Files          105      105           
  Lines         4231     4233    +2     
  Branches       205      206    +1     
========================================
+ Hits          4227     4229    +2     
  Misses           1        1           
  Partials         3        3           
Impacted Files Coverage Δ
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 086be96...a691676. Read the comment docs.

@heitorlessa heitorlessa merged commit a717ca7 into aws-powertools:develop Jun 8, 2021
@heitorlessa heitorlessa deleted the feat/logger-reset-state branch June 8, 2021 08:53
@heitorlessa heitorlessa added this to the 1.17.0 milestone Jun 8, 2021
@heitorlessa heitorlessa added the feature New feature or functionality label Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature or functionality 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