Option to conditionally log to stderr only above a given level
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- rust
- Ambito
- observability
Direzione di ricerca
Inizia individuando la configurazione Target di env_logger e il percorso di Builder::format() menzionato nell'issue. Verifica come i record vengono attualmente instradati verso stdout o stderr, quindi aggiungi un instradamento condizionale in base al livello di log e verifica che i record di livello inferiore usino stdout, mentre i record al livello configurato o superiore usino stderr.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When using env_logger in a binary running in Google Kubernetes Engine, everything it logs gets recorded as an error log because it logs to stderr by default:

This is just the actix-web logger middleware logging requests from the Gcloud healthcheck service at INFO (plus an easter egg of a web crawler looking for an admin login form?), but Gcloud thinks they're error logs because they were printed to stderr.
Of course, we could just set Target::Stdout and call it a day, but I would like to retain the ability to print actual error logs to stderr as we want to set this up to page someone if our API service is throwing actual errors.
I'm thinking another variant to Target that looks something like:
enum Target {
// ...
// Print to `stderr` if the record level is at or above the given `log::Level`, otherwise `stdout`.
StdoutOrStderrAt(log::Level),
}
I'm also considering, as a workaround, using the Builder::format() method to conditionally print to stderr but I'm not sure if this would break things. It's suboptimal either way:
builder.format(|f, record| {
if record.level() >= log::Level::Error {
eprintln!(/* format `record` using the same format as the default formatter */)
} else {
write!(fmt, "{}", record.args())
}
})
- Lingua principale
- Rust
- Stelle
- 1.1k
- Fork
- 150
- Merge medio
- 3m
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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.
Altre issue di rust-cli/env_logger
-
Sanitization requires color, which parses every recordForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
rust-cli/env_logger#419 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
rust-cli/env_logger#379 · 5 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
rust-cli/env_logger#369 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
rust-cli/env_logger#367 · 1 commento ·
-
refactor the crate to separate the provided configurable formater and the optional custom formatterAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
rust-cli/env_logger#365 · 10 commenti ·
Tutte le issue di rust-cli/env_logger
Issue simili
-
agent:sonnet-high enhancement priority: P2 ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
shep-pm/shep-kelpie#652 ·
I maintainer di solito rispondono entro 1 giorno
-
install.ps1: Windows PowerShell 5.1 aborts after a successful cosign verification (NativeCommandError on 'Verified OK')Forse già presa @sly321-pixel l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
ai_p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ClickHouse/ClickHouse#125522 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: OpenRouter streaming chunks report the requested router name instead of the model OpenRouter servedForse già presa @Mrun25 l’ha presa oggi. Apertabug llm translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BerriAI/litellm#46095 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno