Make logger setup callable twice, to simplify life for callers
+use std::sync::Once;
+
+static SETUP: Once = Once::new();
+
/// ## On native: uses env_log
///
/// You can adjust the log level without recompiling with the RUST_LOG env variable.
/// ```
///
/// ## On web: uses console_log
+///
+/// Can be called multiple times
pub fn setup() {
+ SETUP.call_once(|| {
#[cfg(target_arch = "wasm32")]
{
console_log::init_with_level(log::Level::Info).unwrap();
@@ -46,4 +53,5 @@ pub fn setup() {
use env_logger::{Builder, Env};
Builder::from_env(Env::default().default_filter_or("info")).init();
}
+ });
}
