Move logger init earlier in the example framework

This commit is contained in:
Zsolt Bölöny committed 2020-07-19 22:41:27 +02:00
1 parent 8e4d001586
commit 10538f8a9f
1 file changed
+7 -3
+7 -3
View File
@@ -69,6 +69,12 @@ struct Setup {
}
async fn setup<E: Example>(title: &str) -> Setup {
#[cfg(not(target_arch = "wasm32"))]
env_logger::init();
#[cfg(target_arch = "wasm32")]
console_log::init().expect("could not initialize logger");
let event_loop = EventLoop::new();
let mut builder = winit::window::WindowBuilder::new();
builder = builder.with_title(title);
@@ -141,8 +147,6 @@ fn start<E: Example>(
) {
#[cfg(not(target_arch = "wasm32"))]
let (mut pool, spawner) = {
env_logger::init();
#[cfg(feature = "subscriber")]
{
let chrome_tracing_dir = std::env::var("WGPU_CHROME_TRACING");
@@ -170,7 +174,7 @@ fn start<E: Example>(
}
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init().expect("could not initialize logger");
// On wasm, append the canvas to the document body
web_sys::window()
.and_then(|win| win.document())