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

Use log.exception where more economical than log.error #27517

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

dstandish
Copy link
Contributor

When we do log.error(..., exc_info=True), then log.exception is cleaner.

When we do log.error(..., exc_info=True), then log.exception is cleaner.
raise ValueError("failure")

mock_error.assert_called_once_with("failure", exc_info=True)
assert "ValueError: failure" in caplog.text
Copy link
Contributor Author

Choose a reason for hiding this comment

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

using caplog is a better test because it doesn't depend precisely on the code structure, doesn't require mocking -- just looks at the log output

@jedcunningham jedcunningham merged commit 8c15b0a into apache:main Nov 7, 2022
@jedcunningham jedcunningham deleted the log-exception-over-log-error branch November 7, 2022 17:39
@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:logging area:providers provider:cncf-kubernetes Kubernetes provider related issues type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants