From 5c352eb8637d73e4ec2dc364bcf21e2f6a1e20cf Mon Sep 17 00:00:00 2001 From: filipriec Date: Wed, 23 Apr 2025 11:29:00 +0200 Subject: [PATCH] tracing running only when enabled --- README.md | 4 ++++ client/src/main.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index df7eb48..19400a1 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,7 @@ Client: cargo watch -x 'run --package client -- client' ``` +Client with tracing: +``` +ENABLE_TRACING=1 RUST_LOG=client=debug cargo watch -x 'run --package client -- client' +``` diff --git a/client/src/main.rs b/client/src/main.rs index 4f3e375..92eb525 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -3,10 +3,13 @@ use client::run_ui; use dotenvy::dotenv; use anyhow::Result; use tracing_subscriber; +use std::env; #[tokio::main] async fn main() -> Result<()> { - tracing_subscriber::fmt::init(); + if env::var("ENABLE_TRACING").is_ok() { + tracing_subscriber::fmt::init(); + } dotenv().ok(); run_ui().await