Add `AnyLogger` type (`Logger | LoggerAdapter` alias)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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:
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den Einstiegspunkten Logger und LoggerAdapter des logging-Moduls und prüfe den im Issue gezeigten vorgeschlagenen TypeAlias. Sieh dir den früheren Pull Request an, um den Implementierungskontext zu verstehen, und bestätige anschließend, dass der resultierende Typ beide Logger-Formen abdeckt, ohne ihr dokumentiertes Verhalten zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100