Skip to content

Comments

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

Merged
jedcunningham merged 1 commit intoapache:mainfrom
astronomer:log-exception-over-log-error
Nov 7, 2022
Merged

Use log.exception where more economical than log.error#27517
jedcunningham merged 1 commit intoapache:mainfrom
astronomer:log-exception-over-log-error

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.
@boring-cyborg boring-cyborg bot added provider:cncf-kubernetes Kubernetes (k8s) provider related issues area:logging area:providers labels Nov 5, 2022
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 (k8s) provider related issues type:improvement Changelog: Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants