From 0d93ac31a3ab3cd8a60a539ec9083ec8c7b3a611 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 15 Nov 2024 11:43:27 +0100 Subject: [PATCH] Working browser console logs --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/frontend/api.rs | 2 +- src/frontend/mod.rs | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 758932c..6f4b086 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -585,6 +585,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "console_log" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8aed40e4edbf4d3b4431ab260b63fdc40f5780a4766824329ea0f1eefe3c0f" +dependencies = [ + "log", + "web-sys", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -1783,6 +1793,7 @@ dependencies = [ "codee", "config", "console_error_panic_hook", + "console_log", "diesel", "diesel-derive-newtype", "diesel_migrations", diff --git a/Cargo.toml b/Cargo.toml index ce27115..ee4c72a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,6 +119,7 @@ async-trait = { version = "0.1.83", optional = true } config = { version = "0.14.0", features = ["toml"], optional = true } tower = { version = "0.5.1", optional = true } tower-layer = { version = "0.3.3", optional = true } +console_log = "1.0.0" [dev-dependencies] pretty_assertions = "1.4.1" diff --git a/src/frontend/api.rs b/src/frontend/api.rs index 79bcfa2..abfc016 100644 --- a/src/frontend/api.rs +++ b/src/frontend/api.rs @@ -50,7 +50,7 @@ impl ApiClient { let ssl; #[cfg(not(feature = "ssr"))] { - use leptos_use::{use_document}; + use leptos_use::use_document; hostname = use_document().location().unwrap().host().unwrap(); ssl = !cfg!(debug_assertions); } diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 7dcecaf..bebe740 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -14,6 +14,7 @@ pub mod pages; #[wasm_bindgen::prelude::wasm_bindgen] pub fn hydrate() { use crate::frontend::app::App; + console_log::init_with_level(log::Level::Debug).expect("error initializing logger"); console_error_panic_hook::set_once(); leptos::mount_to_body(App); }