1250 - add NO_COLOR env var to disable logs colors (#1503)

Fix #1250

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1503
Reviewed-by: Alex <lx@deuxfleurs.fr>
This commit is contained in:
i5-650
2026-08-19 08:03:44 +00:00
committed by Alex
parent c3c8af9a66
commit d9b1dba137
2 changed files with 8 additions and 0 deletions
@@ -175,6 +175,9 @@ they do not exist in the configuration file:
Garage daemon send its logs to `journald` (using the native protocol of `systemd-journald`) Garage daemon send its logs to `journald` (using the native protocol of `systemd-journald`)
instead of printing to stderr. instead of printing to stderr.
- `NO_COLOR` (since `v2.4.0`): set this to `0` or `false` to disable
ANSI color codes in Garage's logs.
The following environment variables can be used to override the corresponding The following environment variables can be used to override the corresponding
values in the configuration file: values in the configuration file:
+5
View File
@@ -276,6 +276,11 @@ fn init_logging(opt: &Opt) {
tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_writer(std::io::stderr) .with_writer(std::io::stderr)
.with_env_filter(env_filter) .with_env_filter(env_filter)
.with_ansi(
std::env::var("NO_COLOR")
.map(|x| x != "0" && !x.eq_ignore_ascii_case("false"))
.unwrap_or(true),
)
.init(); .init();
} }