Add `AnyLogger` type (`Logger | LoggerAdapter` alias)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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:
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dagli entry point Logger e LoggerAdapter del modulo logging ed esamina il TypeAlias proposto mostrato nell’issue. Controlla la pull request precedente per il contesto dell’implementazione, quindi conferma che il tipo risultante copra entrambe le forme di logger senza modificarne il comportamento documentato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Funzionalità
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100