Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

refactor the crate to separate the provided configurable formater and the optional custom formatter

Aperta
#365 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
rust

Direzione di ricerca

Inizia tracciando le API Builder e Logger descritte nell’issue, incluse fmt::Builder e il percorso del formatter personalizzato. Confronta le opzioni correnti del formatter con i design proposti build_with_custom_formatter e config_builder; il lavoro è completo quando il formatter configurabile è separato dalla formattazione personalizzata senza le attuali asperità dell’API.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

This crate does three things:

  1. It parses environment variables into a verbosity configuration for individual modules (Env)
  2. It filters log messages against said configuration (Logger.filter)
  3. It provides a configurable formater (Logger.format)

You will generally read en environment, convert it to a filter and then combine the filter and a formater into a Logger which you install as default logger.

Technically all three are usable in isolation.
In practice almost everybody is using 2., most people will be using 1. with slight modifications to the default logging level, for example using verbosity flags in clis.

3 is the most commonly exchanged. This is reflected by the builder giving you the option of providing a custom formater.

This functionality should be moved to the Logger. If you want a custom formater you do not interact with the provided configurable formater in any way, but are still forced to use the type to create a Logger.

The current behaviour increases the internal complexity of the Builder struct and leads to weird api crincles. For example after calling Builder.format(|my| fn) technically every try to modify the configurable formatter (ex. format_level) should panic, as that is programmer error (unless ofc it is followed by a call to default_format).

This issue proposes to create a build_with_custom_formatter function instead. This would allow fmt::Builder to be retired.

Also since 90% of the api on the Builder is formatter options a single fn config_builder(|f: formatter|) could reduce duplication.

Lingua principale
Rust
Stelle
1.1k
Fork
149
Merge medio
3h 35m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-cli/env_logger

Tutte le issue di rust-cli/env_logger

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.