1#![doc = include_str!("../README.md")]
2
3use debug_correlation_id::DebugCorrelationId;
4use nameth::NamedType as _;
5
6use self::owned_closure::XOwnedClosure;
7use self::prelude::OrElseLog;
8
9mod attribute;
10mod debug_correlation_id;
11mod element;
12mod key;
13mod node;
14pub mod owned_closure;
15pub mod prelude;
16mod signal;
17mod string;
18mod template;
19mod utils;
20
21pub fn setup_logging() {
25    use tracing_subscriber_wasm::MakeConsoleWriter;
26
27    tracing_subscriber::fmt()
28        .with_max_level(tracing::Level::TRACE)
29        .with_writer(MakeConsoleWriter::default())
30        .without_time()
31        .with_ansi(false)
32        .with_line_number(true)
33        .with_file(true)
34        .with_target(false)
35        .init();
36    let version = "1.0";
37    tracing::trace!(version, "Setting logging: TRACE");
38    tracing::debug!(version, "Setting logging: DEBUG");
39    tracing::info!(version, "Setting logging: INFO");
40    tracing::info!(
41        "{}: {:?}",
42        DebugCorrelationId::<&str>::type_name(),
43        DebugCorrelationId::new(|| "here")
44    );
45
46    if cfg!(feature = "concise_traces") {
48        let closure = XOwnedClosure::new(|self_drop| {
49            move || {
50                let _self_drop = &self_drop;
51                web_sys::console::clear();
52            }
53        });
54        let window = web_sys::window().or_throw("window");
55        window
56            .set_interval_with_callback_and_timeout_and_arguments_0(
57                &closure.as_function().or_throw("as_function"),
58                15 * 60 * 1000,
59            )
60            .or_throw("set_interval");
61    }
62}