refactor: remove redundant debug checks from tracing

This commit is contained in:
Youwen Wu 2024-03-07 13:39:08 -08:00
parent 884014e810
commit 733e798717
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
5 changed files with 9 additions and 5 deletions

1
client/src-tauri/.env Normal file
View file

@ -0,0 +1 @@
RUST_LOG=

View file

@ -3,6 +3,7 @@
use tauri::Manager; use tauri::Manager;
mod telemetry; mod telemetry;
use tracing_subscriber::FmtSubscriber;
#[derive(Clone, serde::Serialize)] #[derive(Clone, serde::Serialize)]
struct Payload { struct Payload {
@ -15,6 +16,12 @@ const NTABLE_PORT: u16 = 5810;
fn main() { fn main() {
let rt = tokio::runtime::Runtime::new().expect("Failed to create Tokio runtime"); let rt = tokio::runtime::Runtime::new().expect("Failed to create Tokio runtime");
// set the environment variable RUST_LOG to debug in order to see debug messages
let subscriber = FmtSubscriber::builder()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.finish();
tracing::subscriber::set_global_default(subscriber).unwrap();
rt.block_on(async { rt.block_on(async {
tauri::Builder::default() tauri::Builder::default()
.setup(|app| { .setup(|app| {

View file

@ -10,7 +10,6 @@ pub fn check_triggers(
match data { match data {
network_tables::Value::Boolean(b) => { network_tables::Value::Boolean(b) => {
if *b != *previous_gpws { if *b != *previous_gpws {
#[cfg(debug_assertions)]
tracing::debug!("gpws: {}", b); tracing::debug!("gpws: {}", b);
app_handle app_handle

View file

@ -32,8 +32,7 @@ pub async fn create_subscription(client: &Client) -> Result<Subscription, networ
match subscription_attempt { match subscription_attempt {
Ok(subscription) => break Ok(subscription), Ok(subscription) => break Ok(subscription),
Err(e) => { Err(e) => {
#[cfg(debug_assertions)] tracing::debug!("Failed to create subscription: {:?}", e);
tracing::warn!("Failed to create subscription: {:?}", e);
if attempts >= 50 { if attempts >= 50 {
break Err(e); break Err(e);

View file

@ -59,11 +59,9 @@ pub async fn subscribe_topics(
}; };
} }
#[cfg(debug_assertions)]
tracing::debug!("{}", json_message); tracing::debug!("{}", json_message);
} }
#[cfg(debug_assertions)]
tracing::debug!("disconnected"); tracing::debug!("disconnected");
app_handle app_handle
.emit_all("telemetry_status", "disconnected") .emit_all("telemetry_status", "disconnected")