summaryrefslogtreecommitdiffstats
path: root/examples/tour
diff options
context:
space:
mode:
authorLibravatar Thomas <thomasbirke@gmx.de>2023-09-09 14:09:48 +0200
committerLibravatar Thomas <thomasbirke@gmx.de>2023-09-09 14:09:48 +0200
commite562544807b196dafac9195ea8137958698755e5 (patch)
tree4cd4040887ee19ee6ebb89cea344d54f8176ca5f /examples/tour
parent9c2ad457d80e8254955396ad034df0dd5f2b59b3 (diff)
downloadiced-e562544807b196dafac9195ea8137958698755e5.tar.gz
iced-e562544807b196dafac9195ea8137958698755e5.tar.bz2
iced-e562544807b196dafac9195ea8137958698755e5.zip
Add logging for web in tour example
Diffstat (limited to '')
-rw-r--r--examples/tour/Cargo.toml5
-rw-r--r--examples/tour/src/main.rs7
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())