From 2580676c76c993d6b7f945beec74fa943f1bd77b Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Tue, 22 Jul 2025 16:48:43 +0200 Subject: [PATCH] add tokio console --- Cargo.lock | 1 + nym-node/Cargo.toml | 4 ++++ nym-node/src/logging.rs | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db6b1431bf..eed4737407 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6617,6 +6617,7 @@ dependencies = [ "chacha", "clap", "colored", + "console-subscriber", "criterion", "csv", "cupid", diff --git a/nym-node/Cargo.toml b/nym-node/Cargo.toml index 96be330954..04f7017243 100644 --- a/nym-node/Cargo.toml +++ b/nym-node/Cargo.toml @@ -38,6 +38,7 @@ tracing-indicatif = { workspace = true } tracing-subscriber.workspace = true tokio = { workspace = true, features = ["macros", "sync", "rt-multi-thread"] } tokio-util = { workspace = true, features = ["codec"] } +console-subscriber = { workspace = true, optional = true } toml = { workspace = true } url = { workspace = true, features = ["serde"] } zeroize = { workspace = true, features = ["zeroize_derive"] } @@ -123,6 +124,9 @@ harness = false # temporary bonding information v1 (to grab and parse nym-mixnode and nym-gateway package versions) cargo_metadata = { workspace = true } +[features] +console = ["console-subscriber"] + [dev-dependencies] criterion = { workspace = true, features = ["async_tokio"] } rand_chacha = { workspace = true } diff --git a/nym-node/src/logging.rs b/nym-node/src/logging.rs index 4852b68635..b4e5eb9cab 100644 --- a/nym-node/src/logging.rs +++ b/nym-node/src/logging.rs @@ -6,6 +6,9 @@ use tracing_subscriber::filter::Directive; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; +#[cfg(feature = "console")] +use console_subscriber; + pub(crate) fn granual_filtered_env() -> anyhow::Result { fn directive_checked(directive: impl Into) -> anyhow::Result { directive.into().parse().map_err(From::from) @@ -22,9 +25,19 @@ pub(crate) fn granual_filtered_env() -> anyhow::Result anyhow::Result { - Ok(tracing_subscriber::registry() + let registry = tracing_subscriber::registry() .with(default_tracing_fmt_layer(std::io::stderr)) - .with(granual_filtered_env()?)) + .with(granual_filtered_env()?); + + #[cfg(feature = "console")] + { + Ok(registry.with(console_subscriber::spawn())) + } + + #[cfg(not(feature = "console"))] + { + Ok(registry) + } } pub(crate) fn setup_tracing_logger() -> anyhow::Result<()> {