mod app;
mod display;

use app::App;
use leptos::{mount_to_body, view};
use tracing_subscriber::{
    fmt::{format::Pretty, time::OffsetTime},
    layer::SubscriberExt,
    util::SubscriberInitExt as _,
};
use tracing_web::{performance_layer, MakeWebConsoleWriter};

fn main() -> anyhow::Result<()> {
    std::panic::set_hook(Box::new(console_error_panic_hook::hook));
    let fmt_layer = tracing_subscriber::fmt::layer()
        .with_ansi(false)
        .with_timer(OffsetTime::local_rfc_3339()?)
        .with_writer(MakeWebConsoleWriter::new());
    let perf_layer = performance_layer().with_details_from_fields(Pretty::default());
    tracing_subscriber::registry()
        .with(fmt_layer)
        .with(perf_layer)
        .init();

    mount_to_body(move || view! { <App/> });
    Ok(())
}