diff options
| author | 2023-09-09 14:09:48 +0200 | |
|---|---|---|
| committer | 2023-09-09 14:09:48 +0200 | |
| commit | e562544807b196dafac9195ea8137958698755e5 (patch) | |
| tree | 4cd4040887ee19ee6ebb89cea344d54f8176ca5f /examples | |
| parent | 9c2ad457d80e8254955396ad034df0dd5f2b59b3 (diff) | |
| download | iced-e562544807b196dafac9195ea8137958698755e5.tar.gz iced-e562544807b196dafac9195ea8137958698755e5.tar.bz2 iced-e562544807b196dafac9195ea8137958698755e5.zip | |
Add logging for web in tour example
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/tour/Cargo.toml | 5 | ||||
| -rw-r--r-- | examples/tour/src/main.rs | 7 | 
2 files changed, 12 insertions, 0 deletions
| diff --git a/examples/tour/Cargo.toml b/examples/tour/Cargo.toml index 9de017ce..11920e0d 100644 --- a/examples/tour/Cargo.toml +++ b/examples/tour/Cargo.toml @@ -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 diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index af508206..f0e3c0cd 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -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()) | 
