Add logging for web in tour example

This commit is contained in:
Thomas 2023-09-09 14:09:48 +02:00
parent 9c2ad457d8
commit e562544807
2 changed files with 12 additions and 0 deletions

View file

@ -9,8 +9,13 @@ publish = false
iced.workspace = true
iced.features = ["image", "debug"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tracing-subscriber = "0.3"
[target.'cfg(target_arch = "wasm32")'.dependencies]
iced.workspace = true
iced.features = ["image", "debug", "webgl"]
console_error_panic_hook = "0.1"
console_log = "1.0"
log.workspace = true

View file

@ -8,6 +8,13 @@ use iced::widget::{Button, Column, Container, Slider};
use iced::{Color, Element, Font, Length, Renderer, Sandbox, Settings};
pub fn main() -> iced::Result {
#[cfg(target_arch = "wasm32")]
{
console_log::init_with_level(log::Level::Debug).expect("Initialize logger");
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
}
#[cfg(not(target_arch = "wasm32"))]
tracing_subscriber::fmt::init();
Tour::run(Settings::default())