Add `AnyLogger` type (`Logger | LoggerAdapter` alias)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
AnyLogger: TypeAlias = Logger | LoggerAdapter
According to the docs, LoggerAdapter should look mostly like Logger. So it would be really nice to have a type that can be used for both Logger and LoggerAdapter.
I would need it when I want to hold a logger instance, but I don't really care if it's Logger or LoggerAdapter.
So I want to support both options.
It may sound like an antipattern, according to the docs, but using LoggerAdapter is the recommended way of passing contextual info (according to the docs).
Even when using contextvars for holding the logger, a AnyLogger type would be handy indeed.
I am willing to submit a PR fixing this issue, like I tried to do before:
https://github.com/python/cpython/pull/126057
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the logging module's Logger and LoggerAdapter entry points and review the proposed TypeAlias shown in the issue. Check the earlier pull request for implementation context, then confirm that the resulting type covers both logger forms without changing their documented behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100