// client/src/main.rs
use client::run_ui;
#[cfg(feature = "ui-debug")]
use client::utils::debug_logger::UiDebugWriter;
use dotenvy::dotenv;
use anyhow::Result;
use tracing_subscriber;
use std::env;

#[tokio::main]
async fn main() -> Result<()> {
    #[cfg(feature = "ui-debug")]
    {
        // If ui-debug is on, set up our custom writer.
        let writer = UiDebugWriter::new();
        tracing_subscriber::fmt()
            .with_level(false) // Don't show INFO, ERROR, etc.
            .with_target(false) // Don't show the module path.
            .without_time() // This is the correct and simpler method.
            .with_writer(move || writer.clone())
            .init();
    }
    #[cfg(not(feature = "ui-debug"))]
    {
        if env::var("ENABLE_TRACING").is_ok() {
            tracing_subscriber::fmt::init();
        }
    }

    dotenv().ok();
    run_ui().await
}
