diff --git a/Cargo.lock b/Cargo.lock index bb667647..6e0db0cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6520,6 +6520,7 @@ dependencies = [ "indexmap", "inferno", "lazy_static", + "log", "metrics", "metrics-exporter-prometheus", "num-integer", diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index 39347803..38bd7aac 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -75,6 +75,10 @@ rand = { version = "0.8.5", package = "rand" } sentry-tracing = { version = "0.23.0", optional = true } sentry = { version = "0.23.0", default-features = false, features = ["backtrace", "contexts", "reqwest", "rustls"], optional = true } +# zebrad uses tracing for logging, +# we only use `log` to print the static log levels in transitive dependencies +log = "0.4.14" + # test feature proptest-impl proptest = { version = "0.10.1", optional = true } proptest-derive = { version = "0.3.0", optional = true } diff --git a/zebrad/src/components/tracing/component.rs b/zebrad/src/components/tracing/component.rs index ad55f5f7..eff9492e 100644 --- a/zebrad/src/components/tracing/component.rs +++ b/zebrad/src/components/tracing/component.rs @@ -31,7 +31,7 @@ impl Tracing { // Construct a tracing subscriber with the supplied filter and enable reloading. let builder = FmtSubscriber::builder() .with_ansi(use_color) - .with_env_filter(filter) + .with_env_filter(&filter) .with_filter_reloading(); let filter_handle = builder.reload_handle(); @@ -62,6 +62,13 @@ impl Tracing { (Some(layer1), Some(layer2)) => subscriber.with(layer1).with(layer2).init(), }; + tracing::info!( + ?filter, + TRACING_STATIC_MAX_LEVEL = ?tracing::level_filters::STATIC_MAX_LEVEL, + LOG_STATIC_MAX_LEVEL = ?log::STATIC_MAX_LEVEL, + "started tracing component", + ); + Ok(Self { filter_handle, flamegrapher, @@ -79,9 +86,19 @@ impl Tracing { /// /// This can be used to provide a dynamic tracing filter endpoint. pub fn reload_filter(&self, filter: impl Into) { + let filter = filter.into(); + let filter_str = filter.to_string(); + self.filter_handle .reload(filter) .expect("the subscriber is not dropped before the component is"); + + tracing::info!( + filter = ?filter_str, + TRACING_STATIC_MAX_LEVEL = ?tracing::level_filters::STATIC_MAX_LEVEL, + LOG_STATIC_MAX_LEVEL = ?log::STATIC_MAX_LEVEL, + "reloaded tracing filter", + ); } }