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 method to return currently configured keys #4033

Merged

Conversation

leandrodamascena
Copy link
Contributor

@leandrodamascena leandrodamascena commented Mar 27, 2024

Issue number: #3505

Summary

Changes

This pull request introduces a new method current_keys to the Logger utility. The primary objective of this method is to offer a straightforward approach for retrieving the currently configured keys utilized within the logger. Additionally, it serves to prevent mistakes such as overwriting keys.

User experience

from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext

logger = Logger()


@logger.inject_lambda_context
def lambda_handler(event: dict, context: LambdaContext) -> str:
    logger.info("Collecting payment")

    if "order" not in logger.get_current_keys():
        logger.append_keys(order=event.get("order"))

    return "hello world"

Checklist

If your change doesn't seem to apply, please leave them unchecked.

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.

@leandrodamascena leandrodamascena requested a review from a team as a code owner March 27, 2024 22:59
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation logger tests labels Mar 27, 2024
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 27, 2024
@leandrodamascena leandrodamascena marked this pull request as draft March 27, 2024 22:59
@github-actions github-actions bot added feature New feature or functionality and removed documentation Improvements or additions to documentation labels Mar 27, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Mar 27, 2024
@leandrodamascena leandrodamascena changed the title feat(logger): Add method to return currently configured keys feat(logger): Add method to return currently configured keys - WIP Mar 27, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Mar 27, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Mar 27, 2024
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 27, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Mar 27, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.25%. Comparing base (e14e768) to head (ddb544e).
Report is 295 commits behind head on develop.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4033      +/-   ##
===========================================
- Coverage    96.38%   96.25%   -0.13%     
===========================================
  Files          214      216       +2     
  Lines        10030    10393     +363     
  Branches      1846     1927      +81     
===========================================
+ Hits          9667    10004     +337     
- Misses         259      275      +16     
- Partials       104      114      +10     

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

docs/core/logger.md Outdated Show resolved Hide resolved
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 1, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 1, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 1, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 1, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 1, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 1, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 10, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 10, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 10, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 10, 2024
Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

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

Great stuff! Just left two tiny comments

aws_lambda_powertools/logging/logger.py Outdated Show resolved Hide resolved
docs/core/logger.md Outdated Show resolved Hide resolved
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 10, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 10, 2024
Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

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

Waiting for the changes discussed offline

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 10, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 10, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 10, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 10, 2024
Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

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

Awesome work :D

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 12, 2024
Copy link

sonarcloud bot commented Apr 12, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Apr 12, 2024
@leandrodamascena leandrodamascena merged commit 16f4dbe into aws-powertools:develop Apr 12, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality logger size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add property to logger class to return currently configured keys
4 participants