Respect RUST_LOG in default httpd logger

Wire up an EnvFilter that reads RUST_LOG, defaulting
to "info", and enable the env-filter feature unconditionally.
This commit is contained in:
Rūdolfs Ošiņš
2026-07-28 08:42:22 +02:00
parent 19ab609aa3
commit 9b1e1d20e1
5 changed files with 21 additions and 4 deletions
+1 -2
View File
@@ -13,7 +13,6 @@ build = "build.rs"
default = []
logfmt = [
"tracing-logfmt",
"tracing-subscriber/env-filter"
]
[[bin]]
@@ -46,7 +45,7 @@ tokio-util = { version = "0.7.18", default-features = false, features = ["io"] }
tower-http = { version = "0.6.6", default-features = false, features = ["trace", "cors", "set-header", "decompression-full"] }
tracing.workspace = true
tracing-logfmt = { version = "0.3.5", optional = true }
tracing-subscriber.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }
url = { version = "2.5.4", features = ["serde"] }
uuid = { version = "1.13.1", features = ["serde"] }
@@ -20,6 +20,13 @@ A Radicle HTTP daemon exposing a JSON HTTP API that allows someone to browse loc
repositories on a Radicle node via their web browser. This manual page is a
placeholder to point you at the *--help* option.
== Environment
*RUST_LOG*::
Sets the log level. Accepts standard `tracing`/`env_logger`-style directives,
for example `RUST_LOG=warn` or `RUST_LOG=radicle_httpd=debug`. Defaults to
`info` when unset.
== SEE ALSO ==
*rad*(1)
+5 -1
View File
@@ -237,9 +237,13 @@ pub mod logger {
#[cfg(not(feature = "logfmt"))]
pub fn subscriber() -> impl tracing::Subscriber {
use tracing_subscriber::EnvFilter;
tracing_subscriber::FmtSubscriber::builder()
.with_target(false)
.with_max_level(tracing::Level::DEBUG)
.with_env_filter(
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
)
.finish()
}
}
+5
View File
@@ -29,6 +29,11 @@ Options
--cache <number> Max amount of items in cache for /tree endpoints (default: 100)
--version, -v Print program version
--help, -h Print help
Environment
RUST_LOG Set the log level (e.g. RUST_LOG=warn, or
RUST_LOG=radicle_httpd=debug). Defaults to "info".
"#;
#[tokio::main]
+3 -1
View File
@@ -24,6 +24,8 @@ Environment
RADICLE_SEARCH_RESCAN_SECS Periodic full rescan interval in seconds (default: 3600)
RADICLE_SEARCH_RECONNECT_BACKOFF_SECS Reconnect delay after a dropped event stream (default: 5)
RAD_HOME, RAD_SOCKET Standard Radicle paths
RUST_LOG Log level, e.g. RUST_LOG=warn or
RUST_LOG=radicle_search=debug (default: info)
"#;
#[tokio::main]
@@ -43,7 +45,7 @@ async fn main() {
fn init_tracing() {
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("radicle_search=info,info"));
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"));
tracing_subscriber::fmt().with_env_filter(filter).init();
}