Add logging parameter to retry decorator for automatic retry logging
- Dominant language
- Python
- Stars
- 8.8k
- Forks
- 359
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
Currently, logging retry attempts with tenacity requires manually wiring before, after, and retry_error_callback hooks every time. This is verbose and repetitive for a common use case.
Proposal: Add an optional logging parameter to the retry decorator that automatically sets sensible callbacks using stdlib logging:
```
python@retry(stop=stop_after_attempt(3), logging=True)
def my_function():
...
```
This would log:
- Each retry attempt (attempt number, wait time)
- The final exception if all attempts fail
The existing before/after/retry_error_callback hooks remain unchanged, this is purely additive as a convenience wrapper over them.
Motivation: Similar to how requests integrates with logging automatically, this would make tenacity friendlier for production use without any breaking changes.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the retry decorator and inspect how the existing before, after, and retry_error_callback hooks are configured and invoked. Define the optional logging parameter without changing those hooks, then verify that retry attempts and the final exception are logged with the requested details and that existing behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100