mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 19:30:38 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user