use tracing::Level;
use tracing_subscriber::fmt::format::Pretty;
use tracing_subscriber::prelude::*;
use tracing_web::{performance_layer, MakeWebConsoleWriter};
use wasm_bindgen::prelude::wasm_bindgen;
pub mod assets;
pub mod websocket;
/// --- IMPORTANT: THIS IS A DUAL TARGET CRATE ---
/// THIS WILL ONLY EXECUTE ON WEBASSEMBLY
/// DO ONLY PLATFORM SPECIFIC INITIALIZATION HERE
/// FOR ACTUAL PROGRAM LOGIC, EDIT `crate::start`
/// DO NOT RENAME
#[wasm_bindgen(start)]
pub fn entrypoint() {
// Panic handler
console_error_panic_hook::set_once();
/* ----- Logging setup ----- */
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(false) // not supported in browsers
.without_time() // std::time doesn't exist in wasm
.with_writer(MakeWebConsoleWriter::new().with_max_level(Level::DEBUG)); // wgpu spams the console, and this is slow as hell
let perf_layer = performance_layer() // enable performance tracing
.with_details_from_fields(Pretty::default()); // ... with pretty fields
tracing_subscriber::registry()
.with(fmt_layer)
.with(perf_layer)
.init(); // register the logger
// All done with platform-specific initialization, call back into the common code path
crate::start();
}