Skip to content

fix(logger): support exception and exception_name fields at any log level #1930

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
merged 3 commits into from
Feb 15, 2023

Conversation

iago1460
Copy link
Contributor

@iago1460 iago1460 commented Feb 15, 2023

Issue number: #1923

Summary

Providing fix for reporting entry logs with custom exception and exception_name fields

Changes

Changed format log to honor exception and exception_name fields

User experience

given:

logger.info("Report", extra={"exception": "Oops!  That was not valid", "exception_name": "ValueError" })

before:

{
        "level": "INFO",
        "message": "Report"
}

after:

{
        "level": "INFO",
        "message": "Report",
        "exception": "Oops!  That was not valid",
        "exception_name": "ValueError",
}

Checklist

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

Is this a breaking change? no

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.

@iago1460 iago1460 requested a review from a team as a code owner February 15, 2023 15:40
@iago1460 iago1460 requested review from leandrodamascena and removed request for a team February 15, 2023 15:40
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 15, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 15, 2023

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: Invite link

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

LGTM :)

)

# WHEN log level info
logger.info("log")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: add the exception fields here so it's easier to scan and understand what's being tested.

logger.info("log", exception=..., exception_name=...)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch @heitorlessa! Thank you!

@leandrodamascena leandrodamascena changed the title fix(logger) Allow reporting entry logs with custom exception and exce… fix(logger) Allow reporting entry logs with custom exception fields Feb 15, 2023
@leandrodamascena leandrodamascena changed the title fix(logger) Allow reporting entry logs with custom exception fields fix(logger): Allow reporting entry logs with custom exception fields Feb 15, 2023
@github-actions github-actions bot added the bug Something isn't working label Feb 15, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2023

Codecov Report

Base: 97.44% // Head: 97.45% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (ba9b84f) compared to base (18b9b19).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1930   +/-   ##
========================================
  Coverage    97.44%   97.45%           
========================================
  Files          144      144           
  Lines         6627     6629    +2     
  Branches       475      475           
========================================
+ Hits          6458     6460    +2     
  Misses         132      132           
  Partials        37       37           
Impacted Files Coverage Δ
aws_lambda_powertools/logging/formatter.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@leandrodamascena leandrodamascena changed the title fix(logger): Allow reporting entry logs with custom exception fields fix(logger): support exception and exception_name fields at any log level Feb 15, 2023
@leandrodamascena leandrodamascena merged commit 75b6924 into aws-powertools:develop Feb 15, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 15, 2023

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logger size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Allow reporting entry logs with custom exception and exception_name
4 participants