Option to conditionally log to stderr only above a given level
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- rust
- Bereich
- observability
Rechercherichtung
Beginne damit, die Target-Konfiguration von env_logger und den im Issue erwähnten Pfad von Builder::format() zu finden. Prüfe, wie Records derzeit an stdout oder stderr weitergeleitet werden, füge dann eine bedingte Weiterleitung nach Log-Level hinzu und verifiziere, dass Records mit niedrigerem Level stdout verwenden, während Records auf oder über dem konfigurierten Level stderr verwenden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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())
}
})
- Vorherrschende Sprache
- Rust
- Sterne
- 1.1k
- Forks
- 150
- Ø Merge
- 2 Min.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rust-cli/env_logger
-
Sanitization requires color, which parses every recordEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
rust-cli/env_logger#419 · 2 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
rust-cli/env_logger#379 · 5 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
rust-cli/env_logger#369 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
rust-cli/env_logger#367 · 1 Kommentar ·
-
refactor the crate to separate the provided configurable formater and the optional custom formatterOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
rust-cli/env_logger#365 · 10 Kommentare ·
Alle Issues in rust-cli/env_logger
Ähnliche Issues
-
bug easy good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
lacs-project/sysknife#659 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
registrystack/registry-stack#2431 ·
Maintainer antworten meist innerhalb von 1 Tag
-
contribution
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
farion1231/cc-switch#8863 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
DioxusLabs/dioxus#6006 ·
Maintainer antworten meist innerhalb von 1 Tag