switch to tracing for logging

This commit is contained in:
Evan Almloff committed 2023-09-06 17:47:33 -05:00
1 parent c8127e164b
commit c55c17cb81
50 files changed
+95 -78

No files matched your search

+2
View File
@@ -83,6 +83,8 @@ dioxus-hot-reload = { path = "packages/hot-reload", version = "0.4.0" }
dioxus-fullstack = { path = "packages/fullstack", version = "0.4.1" } dioxus-fullstack = { path = "packages/fullstack", version = "0.4.1" }
dioxus_server_macro = { path = "packages/server-macro", version = "0.4.1" } dioxus_server_macro = { path = "packages/server-macro", version = "0.4.1" }
log = "0.4.19" log = "0.4.19"
tracing = "0.1.37"
tracing-futures = "0.2.5"
tokio = "1.28" tokio = "1.28"
slab = "0.4.2" slab = "0.4.2"
futures-channel = "0.3.21" futures-channel = "0.3.21"
+1 -1
View File
@@ -28,7 +28,7 @@ slab = { workspace = true }
futures-channel = { workspace = true } futures-channel = { workspace = true }
smallbox = "0.8.1" smallbox = "0.8.1"
log = { workspace = true } tracing = { workspace = true }
# Serialize the Edits for use in Webview/Liveview instances # Serialize the Edits for use in Webview/Liveview instances
serde = { version = "1", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }
+1 -1
View File
@@ -68,7 +68,7 @@ unsafe impl<'a, P> AnyProps<'a> for VProps<'a, P> {
Ok(None) => RenderReturn::default(), Ok(None) => RenderReturn::default(),
Err(err) => { Err(err) => {
let component_name = cx.name(); let component_name = cx.name();
log::error!("Error while rendering component `{component_name}`: {err:?}"); tracing::error!("Error while rendering component `{component_name}`: {err:?}");
RenderReturn::default() RenderReturn::default()
} }
} }
+7 -1
View File
@@ -196,7 +196,8 @@ impl<'b> VirtualDom {
right.scope.set(Some(scope_id)); right.scope.set(Some(scope_id));
// copy out the box for both // copy out the box for both
let old = self.scopes[scope_id.0].props.as_ref(); let old_scope = &self.scopes[scope_id.0];
let old = old_scope.props.as_ref();
let new: Box<dyn AnyProps> = right.props.take().unwrap(); let new: Box<dyn AnyProps> = right.props.take().unwrap();
let new: Box<dyn AnyProps> = unsafe { std::mem::transmute(new) }; let new: Box<dyn AnyProps> = unsafe { std::mem::transmute(new) };
@@ -204,6 +205,11 @@ impl<'b> VirtualDom {
// The target scopestate still has the reference to the old props, so there's no need to update anything // The target scopestate still has the reference to the old props, so there's no need to update anything
// This also implicitly drops the new props since they're not used // This also implicitly drops the new props since they're not used
if left.static_props && unsafe { old.as_ref().unwrap().memoize(new.as_ref()) } { if left.static_props && unsafe { old.as_ref().unwrap().memoize(new.as_ref()) } {
tracing::trace!(
"Memoized props for component {:#?} ({})",
scope_id,
old_scope.context().name
);
return; return;
} }
+1 -1
View File
@@ -118,7 +118,7 @@ impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
/// ///
/// ```rust, ignore /// ```rust, ignore
/// rsx!{ /// rsx!{
/// MyComponent { onclick: move |evt| log::info!("clicked") } /// MyComponent { onclick: move |evt| tracing::debug!("clicked") }
/// } /// }
/// ///
/// #[derive(Props)] /// #[derive(Props)]
+1
View File
@@ -64,6 +64,7 @@ impl VirtualDom {
let props: &dyn AnyProps = scope.props.as_ref().unwrap().as_ref(); let props: &dyn AnyProps = scope.props.as_ref().unwrap().as_ref();
let props: &dyn AnyProps = std::mem::transmute(props); let props: &dyn AnyProps = std::mem::transmute(props);
let _span = tracing::trace_span!("render", scope = %scope.context().name);
props.render(scope).extend_lifetime() props.render(scope).extend_lifetime()
}; };
+2 -1
View File
@@ -306,6 +306,7 @@ impl VirtualDom {
pub fn mark_dirty(&mut self, id: ScopeId) { pub fn mark_dirty(&mut self, id: ScopeId) {
if let Some(scope) = self.get_scope(id) { if let Some(scope) = self.get_scope(id) {
let height = scope.height(); let height = scope.height();
tracing::trace!("Marking scope {:?} ({}) as dirty", id, scope.context().name);
self.dirty_scopes.insert(DirtyScope { height, id }); self.dirty_scopes.insert(DirtyScope { height, id });
} }
} }
@@ -558,7 +559,7 @@ impl VirtualDom {
} }
// If an error occurs, we should try to render the default error component and context where the error occured // If an error occurs, we should try to render the default error component and context where the error occured
RenderReturn::Aborted(placeholder) => { RenderReturn::Aborted(placeholder) => {
log::info!("Ran into suspended or aborted scope during rebuild"); tracing::debug!("Ran into suspended or aborted scope during rebuild");
let id = self.next_null(); let id = self.next_null();
placeholder.id.set(Some(id)); placeholder.id.set(Some(id));
self.mutations.push(Mutation::CreatePlaceholder { id }); self.mutations.push(Mutation::CreatePlaceholder { id });
+1 -1
View File
@@ -18,7 +18,7 @@ dioxus-hot-reload = { workspace = true, optional = true }
serde = "1.0.136" serde = "1.0.136"
serde_json = "1.0.79" serde_json = "1.0.79"
thiserror = { workspace = true } thiserror = { workspace = true }
log = { workspace = true } tracing = { workspace = true }
wry = { version = "0.28.0" } wry = { version = "0.28.0" }
futures-channel = { workspace = true } futures-channel = { workspace = true }
tokio = { workspace = true, features = [ tokio = { workspace = true, features = [
+2 -2
View File
@@ -194,7 +194,7 @@ impl DesktopService {
/// launch print modal /// launch print modal
pub fn print(&self) { pub fn print(&self) {
if let Err(e) = self.webview.print() { if let Err(e) = self.webview.print() {
log::warn!("Open print modal failed: {e}"); tracing::warn!("Open print modal failed: {e}");
} }
} }
@@ -209,7 +209,7 @@ impl DesktopService {
self.webview.open_devtools(); self.webview.open_devtools();
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
log::warn!("Devtools are disabled in release builds"); tracing::warn!("Devtools are disabled in release builds");
} }
/// Create a wry event handler that listens for wry events. /// Create a wry event handler that listens for wry events.
+1 -1
View File
@@ -330,7 +330,7 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
if temp.contains_key("href") { if temp.contains_key("href") {
let open = webbrowser::open(temp["href"].as_str().unwrap()); let open = webbrowser::open(temp["href"].as_str().unwrap());
if let Err(e) = open { if let Err(e) = open {
log::error!("Open Browser error: {:?}", e); tracing::error!("Open Browser error: {:?}", e);
} }
} }
} }
+1 -1
View File
@@ -123,7 +123,7 @@ impl QueryEngine {
}}) }})
}})();"# }})();"#
)) { )) {
log::warn!("Query error: {err}"); tracing::warn!("Query error: {err}");
} }
Query { Query {
+1 -1
View File
@@ -30,7 +30,7 @@ hot-reload = ["dioxus-hot-reload"]
[dev-dependencies] [dev-dependencies]
futures-util = { workspace = true } futures-util = { workspace = true }
log = { workspace = true } tracing = { workspace = true }
rand = { version = "0.8.4", features = ["small_rng"] } rand = { version = "0.8.4", features = ["small_rng"] }
criterion = "0.3.5" criterion = "0.3.5"
thiserror = { workspace = true } thiserror = { workspace = true }
+1 -1
View File
@@ -14,7 +14,7 @@ keywords = ["dom", "ui", "gui", "react", "state-management"]
[dependencies] [dependencies]
dioxus-core = { workspace = true } dioxus-core = { workspace = true }
im-rc = { version = "15.0.0", features = ["serde"] } im-rc = { version = "15.0.0", features = ["serde"] }
log = { workspace = true } tracing = { workspace = true }
[dev-dependencies] [dev-dependencies]
closure = "0.3.0" closure = "0.3.0"
+4 -4
View File
@@ -66,14 +66,14 @@ impl AtomRoot {
if let Some(slot) = atoms.get_mut(&ptr) { if let Some(slot) = atoms.get_mut(&ptr) {
slot.value = Rc::new(value); slot.value = Rc::new(value);
log::trace!("found item with subscribers {:?}", slot.subscribers); tracing::trace!("found item with subscribers {:?}", slot.subscribers);
for scope in &slot.subscribers { for scope in &slot.subscribers {
log::trace!("updating subcsriber"); tracing::trace!("updating subcsriber");
(self.update_any)(*scope); (self.update_any)(*scope);
} }
} else { } else {
log::trace!("no atoms found for {:?}", ptr); tracing::trace!("no atoms found for {:?}", ptr);
atoms.insert( atoms.insert(
ptr, ptr,
Slot { Slot {
@@ -96,7 +96,7 @@ impl AtomRoot {
pub fn force_update(&self, ptr: AtomId) { pub fn force_update(&self, ptr: AtomId) {
if let Some(slot) = self.atoms.borrow_mut().get(&ptr) { if let Some(slot) = self.atoms.borrow_mut().get(&ptr) {
for scope in slot.subscribers.iter() { for scope in slot.subscribers.iter() {
log::trace!("updating subcsriber"); tracing::trace!("updating subcsriber");
(self.update_any)(*scope); (self.update_any)(*scope);
} }
} }
+2 -1
View File
@@ -44,7 +44,8 @@ dioxus-desktop = { workspace = true, optional = true }
# Router Integration # Router Integration
dioxus-router = { workspace = true, optional = true } dioxus-router = { workspace = true, optional = true }
log = { workspace = true } tracing = { workspace = true }
tracing-futures = { workspace = true }
once_cell = "1.17.1" once_cell = "1.17.1"
thiserror = { workspace = true } thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"], optional = true } tokio = { workspace = true, features = ["full"], optional = true }
@@ -66,7 +66,7 @@ async fn get_server_data() -> Result<String, ServerFnError> {
fn main() { fn main() {
#[cfg(feature = "web")] #[cfg(feature = "web")]
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); wasm_logger::init(wasm_logger::Config::new(tracing::Level::Trace));
#[cfg(feature = "ssr")] #[cfg(feature = "ssr")]
simple_logger::SimpleLogger::new().init().unwrap(); simple_logger::SimpleLogger::new().init().unwrap();
@@ -60,7 +60,7 @@ async fn get_server_data() -> Result<String, ServerFnError> {
fn main() { fn main() {
#[cfg(feature = "web")] #[cfg(feature = "web")]
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); wasm_logger::init(wasm_logger::Config::new(tracing::Level::Trace));
#[cfg(feature = "ssr")] #[cfg(feature = "ssr")]
simple_logger::SimpleLogger::new().init().unwrap(); simple_logger::SimpleLogger::new().init().unwrap();
@@ -60,7 +60,7 @@ async fn get_server_data() -> Result<String, ServerFnError> {
fn main() { fn main() {
#[cfg(feature = "web")] #[cfg(feature = "web")]
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); wasm_logger::init(wasm_logger::Config::new(tracing::Level::Trace));
#[cfg(feature = "ssr")] #[cfg(feature = "ssr")]
simple_logger::SimpleLogger::new().init().unwrap(); simple_logger::SimpleLogger::new().init().unwrap();
@@ -389,7 +389,7 @@ pub async fn render_handler<P: Clone + serde::Serialize + Send + Sync + 'static>
response response
} }
Err(e) => { Err(e) => {
log::error!("Failed to render page: {}", e); tracing::error!("Failed to render page: {}", e);
report_err(e).into_response() report_err(e).into_response()
} }
} }
@@ -423,7 +423,7 @@ impl<P: Clone + serde::Serialize + Send + Sync + 'static> Handler for SSRHandler
freshness.write(res.headers_mut()); freshness.write(res.headers_mut());
} }
Err(err) => { Err(err) => {
log::error!("Error rendering SSR: {}", err); tracing::error!("Error rendering SSR: {}", err);
res.write_body("Error rendering SSR").unwrap(); res.write_body("Error rendering SSR").unwrap();
} }
}; };
@@ -84,7 +84,7 @@ use warp::{
/// async move { /// async move {
/// let req = warp::hyper::Request::from_parts(parts, bytes.into()); /// let req = warp::hyper::Request::from_parts(parts, bytes.into());
/// service.run(req).await.map_err(|err| { /// service.run(req).await.map_err(|err| {
/// log::error!("Server function error: {}", err); /// tracing::error!("Server function error: {}", err);
/// warp::reject::reject() /// warp::reject::reject()
/// }) /// })
/// } /// }
@@ -142,7 +142,7 @@ pub fn register_server_fns(server_fn_route: &'static str) -> BoxedFilter<(impl R
async move { async move {
let req = warp::hyper::Request::from_parts(parts, bytes.into()); let req = warp::hyper::Request::from_parts(parts, bytes.into());
service.run(req).await.map_err(|err| { service.run(req).await.map_err(|err| {
log::error!("Server function error: {}", err); tracing::error!("Server function error: {}", err);
warp::reject::reject() warp::reject::reject()
}) })
} }
@@ -222,7 +222,7 @@ pub fn render_ssr<P: Clone + serde::Serialize + Send + Sync + 'static>(
res res
} }
Err(err) => { Err(err) => {
log::error!("Failed to render ssr: {}", err); tracing::error!("Failed to render ssr: {}", err);
Response::builder() Response::builder()
.status(500) .status(500)
.body("Failed to render ssr".into()) .body("Failed to render ssr".into())
@@ -23,7 +23,7 @@ pub fn server_cached<O: 'static + Serialize + DeserializeOwned>(server_fn: impl
let data = server_fn(); let data = server_fn();
let sc = crate::prelude::server_context(); let sc = crate::prelude::server_context();
if let Err(err) = sc.push_html_data(&data) { if let Err(err) = sc.push_html_data(&data) {
log::error!("Failed to push HTML data: {}", err); tracing::error!("Failed to push HTML data: {}", err);
} }
data data
} }
@@ -47,13 +47,13 @@ where
if first_run { if first_run {
match crate::html_storage::deserialize::take_server_data() { match crate::html_storage::deserialize::take_server_data() {
Some(data) => { Some(data) => {
log::trace!("Loaded {data:?} from server"); tracing::trace!("Loaded {data:?} from server");
*state.value.borrow_mut() = Some(Box::new(data)); *state.value.borrow_mut() = Some(Box::new(data));
state.needs_regen.set(false); state.needs_regen.set(false);
return Some(state); return Some(state);
} }
None => { None => {
log::trace!("Failed to load from server... running future"); tracing::trace!("Failed to load from server... running future");
} }
}; };
} }
@@ -82,7 +82,7 @@ where
data = fut.await; data = fut.await;
if first_run { if first_run {
if let Err(err) = crate::prelude::server_context().push_html_data(&data) { if let Err(err) = crate::prelude::server_context().push_html_data(&data) {
log::error!("Failed to push HTML data: {}", err); tracing::error!("Failed to push HTML data: {}", err);
}; };
} }
} }
@@ -99,7 +99,7 @@ where
if first_run { if first_run {
#[cfg(feature = "ssr")] #[cfg(feature = "ssr")]
{ {
log::trace!("Suspending first run of use_server_future"); tracing::trace!("Suspending first run of use_server_future");
cx.suspend(); cx.suspend();
} }
None None
+1 -1
View File
@@ -30,7 +30,7 @@ impl Default for HotReloadState {
} }
if let Err(err) = tx.send(Some(template)) { if let Err(err) = tx.send(Some(template)) {
log::error!("Failed to send hot reload message: {}", err); tracing::error!("Failed to send hot reload message: {}", err);
} }
} }
dioxus_hot_reload::HotReloadMsg::Shutdown => { dioxus_hot_reload::HotReloadMsg::Shutdown => {
@@ -10,7 +10,7 @@ pub(crate) fn serde_from_bytes<T: DeserializeOwned>(string: &[u8]) -> Option<T>
let decompressed = match STANDARD.decode(string) { let decompressed = match STANDARD.decode(string) {
Ok(bytes) => bytes, Ok(bytes) => bytes,
Err(err) => { Err(err) => {
log::error!("Failed to decode base64: {}", err); tracing::error!("Failed to decode base64: {}", err);
return None; return None;
} }
}; };
@@ -18,7 +18,7 @@ pub(crate) fn serde_from_bytes<T: DeserializeOwned>(string: &[u8]) -> Option<T>
match postcard::from_bytes(&decompressed) { match postcard::from_bytes(&decompressed) {
Ok(data) => Some(data), Ok(data) => Some(data),
Err(err) => { Err(err) => {
log::error!("Failed to deserialize: {}", err); tracing::error!("Failed to deserialize: {}", err);
None None
} }
} }
@@ -32,14 +32,14 @@ static SERVER_DATA: once_cell::sync::Lazy<Option<HTMLDataCursor>> =
let element = match window.get_element_by_id("dioxus-storage-data") { let element = match window.get_element_by_id("dioxus-storage-data") {
Some(element) => element, Some(element) => element,
None => { None => {
log::error!("Failed to get element by id: dioxus-storage-data"); tracing::error!("Failed to get element by id: dioxus-storage-data");
return None; return None;
} }
}; };
let attribute = match element.get_attribute("data-serialized") { let attribute = match element.get_attribute("data-serialized") {
Some(attribute) => attribute, Some(attribute) => attribute,
None => { None => {
log::error!("Failed to get attribute: data-serialized"); tracing::error!("Failed to get attribute: data-serialized");
return None; return None;
} }
}; };
+2 -2
View File
@@ -36,7 +36,7 @@ impl HTMLDataCursor {
pub fn take<T: DeserializeOwned>(&self) -> Option<T> { pub fn take<T: DeserializeOwned>(&self) -> Option<T> {
let current = self.index.load(std::sync::atomic::Ordering::SeqCst); let current = self.index.load(std::sync::atomic::Ordering::SeqCst);
if current >= self.data.len() { if current >= self.data.len() {
log::error!( tracing::error!(
"Tried to take more data than was available, len: {}, index: {}", "Tried to take more data than was available, len: {}, index: {}",
self.data.len(), self.data.len(),
current current
@@ -48,7 +48,7 @@ impl HTMLDataCursor {
match postcard::from_bytes(cursor) { match postcard::from_bytes(cursor) {
Ok(x) => Some(x), Ok(x) => Some(x),
Err(e) => { Err(e) => {
log::error!("Error deserializing data: {:?}", e); tracing::error!("Error deserializing data: {:?}", e);
None None
} }
} }
+6 -1
View File
@@ -1,4 +1,5 @@
use std::pin::Pin; use std::pin::Pin;
use tracing_futures::Instrument;
use http::{Request, Response}; use http::{Request, Response};
@@ -45,7 +46,11 @@ where
> + Send, > + Send,
>, >,
> { > {
let fut = self.call(req); let fut = self.call(req).instrument(tracing::trace_span!(
"service",
"{}",
std::any::type_name::<S>()
));
Box::pin(async move { fut.await.map_err(|err| err.into()) }) Box::pin(async move { fut.await.map_err(|err| err.into()) })
} }
} }
+4 -4
View File
@@ -50,10 +50,10 @@ impl SsrRendererPool {
let prev_context = let prev_context =
SERVER_CONTEXT.with(|ctx| ctx.replace(server_context)); SERVER_CONTEXT.with(|ctx| ctx.replace(server_context));
// poll the future, which may call server_context() // poll the future, which may call server_context()
log::info!("Rebuilding vdom"); tracing::info!("Rebuilding vdom");
let _ = vdom.rebuild(); let _ = vdom.rebuild();
vdom.wait_for_suspense().await; vdom.wait_for_suspense().await;
log::info!("Suspense resolved"); tracing::info!("Suspense resolved");
// after polling the future, we need to restore the context // after polling the future, we need to restore the context
SERVER_CONTEXT.with(|ctx| ctx.replace(prev_context)); SERVER_CONTEXT.with(|ctx| ctx.replace(prev_context));
@@ -116,10 +116,10 @@ impl SsrRendererPool {
let prev_context = SERVER_CONTEXT let prev_context = SERVER_CONTEXT
.with(|ctx| ctx.replace(Box::new(server_context))); .with(|ctx| ctx.replace(Box::new(server_context)));
// poll the future, which may call server_context() // poll the future, which may call server_context()
log::info!("Rebuilding vdom"); tracing::info!("Rebuilding vdom");
let _ = vdom.rebuild(); let _ = vdom.rebuild();
vdom.wait_for_suspense().await; vdom.wait_for_suspense().await;
log::info!("Suspense resolved"); tracing::info!("Suspense resolved");
// after polling the future, we need to restore the context // after polling the future, we need to restore the context
SERVER_CONTEXT.with(|ctx| ctx.replace(prev_context)); SERVER_CONTEXT.with(|ctx| ctx.replace(prev_context));
}) })
+1 -1
View File
@@ -29,7 +29,7 @@ where
.to_string() .to_string()
.parse() .parse()
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
log::error!("Failed to parse uri: {}", err); tracing::error!("Failed to parse uri: {}", err);
"/" "/"
.parse() .parse()
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
+1 -1
View File
@@ -16,7 +16,7 @@ nightly-features = []
[dependencies] [dependencies]
dioxus-core = { workspace = true } dioxus-core = { workspace = true }
futures-channel = { workspace = true } futures-channel = { workspace = true }
log = { workspace = true } tracing = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
slab = { workspace = true } slab = { workspace = true }
dioxus-debug-cell = "0.1.1" dioxus-debug-cell = "0.1.1"
+1 -1
View File
@@ -108,7 +108,7 @@ impl_event! {
/// ///
/// ## Example /// ## Example
/// ```rust, ignore /// ```rust, ignore
/// rsx!( button { "click me", onclick: move |_| log::info!("Clicked!`") } ) /// rsx!( button { "click me", onclick: move |_| tracing::info!("Clicked!`") } )
/// ``` /// ```
/// ///
/// ## Reference /// ## Reference
+1 -1
View File
@@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
thiserror = { workspace = true } thiserror = { workspace = true }
log = { workspace = true } tracing = { workspace = true }
slab = { workspace = true } slab = { workspace = true }
futures-util = { workspace = true, default-features = false, features = [ futures-util = { workspace = true, default-features = false, features = [
"sink", "sink",
+1 -1
View File
@@ -126,7 +126,7 @@ impl QueryEngine {
}}) }})
}})();"# }})();"#
)) { )) {
log::warn!("Query error: {err}"); tracing::warn!("Query error: {err}");
} }
Query { Query {
+1 -1
View File
@@ -14,7 +14,7 @@ anyhow = "1.0.66"
dioxus = { workspace = true } dioxus = { workspace = true }
dioxus-router-macro = { workspace = true } dioxus-router-macro = { workspace = true }
gloo = { version = "0.8.0", optional = true } gloo = { version = "0.8.0", optional = true }
log = { workspace = true } tracing = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
futures-util = { workspace = true } futures-util = { workspace = true }
urlencoding = "2.1.3" urlencoding = "2.1.3"
@@ -1,5 +1,5 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use log::error; use tracing::error;
use crate::utils::use_router_internal::use_router_internal; use crate::utils::use_router_internal::use_router_internal;
+1 -1
View File
@@ -3,7 +3,7 @@ use std::fmt::Debug;
use std::rc::Rc; use std::rc::Rc;
use dioxus::prelude::*; use dioxus::prelude::*;
use log::error; use tracing::error;
use crate::navigation::NavigationTarget; use crate::navigation::NavigationTarget;
use crate::prelude::Routable; use crate::prelude::Routable;
+1 -1
View File
@@ -139,7 +139,7 @@ impl<R: Routable> WebHistory<R> {
); );
let current_route = myself.current_route(); let current_route = myself.current_route();
log::trace!("initial route: {:?}", current_route); tracing::trace!("initial route: {:?}", current_route);
let current_url = current_route.to_string(); let current_url = current_route.to_string();
let state = myself.create_state(current_route); let state = myself.create_state(current_route);
let _ = replace_state_with_url(&myself.history, &state, Some(&current_url)); let _ = replace_state_with_url(&myself.history, &state, Some(&current_url));
+1 -1
View File
@@ -1,8 +1,8 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use gloo::{events::EventListener, render::AnimationFrame, utils::window}; use gloo::{events::EventListener, render::AnimationFrame, utils::window};
use log::error;
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
use tracing::error;
use url::Url; use url::Url;
use web_sys::{History, ScrollRestoration, Window}; use web_sys::{History, ScrollRestoration, Window};
+2 -2
View File
@@ -59,8 +59,8 @@ where
.await?; .await?;
} }
Err(e) => { Err(e) => {
log::info!("@ route: {}", full_path); tracing::info!("@ route: {}", full_path);
log::error!("Error pre-caching static route: {}", e); tracing::error!("Error pre-caching static route: {}", e);
} }
} }
} }
+2 -2
View File
@@ -57,7 +57,7 @@ where
match urlencoding::decode(route) { match urlencoding::decode(route) {
Ok(segment) => T::from_str(&segment), Ok(segment) => T::from_str(&segment),
Err(err) => { Err(err) => {
log::error!("Failed to decode url encoding: {}", err); tracing::error!("Failed to decode url encoding: {}", err);
T::from_str(route) T::from_str(route)
} }
} }
@@ -87,7 +87,7 @@ where
match urlencoding::decode(&segment) { match urlencoding::decode(&segment) {
Ok(segment) => write!(f, "{}", segment)?, Ok(segment) => write!(f, "{}", segment)?,
Err(err) => { Err(err) => {
log::error!("Failed to decode url encoding: {}", err); tracing::error!("Failed to decode url encoding: {}", err);
write!(f, "{}", segment)? write!(f, "{}", segment)?
} }
} }
+1 -1
View File
@@ -9,7 +9,7 @@ edition = "2018"
[dependencies] [dependencies]
dioxus-core = { workspace = true } dioxus-core = { workspace = true }
generational-box = { workspace = true } generational-box = { workspace = true }
log.workspace = true tracing = { workspace = true }
simple_logger = "4.2.0" simple_logger = "4.2.0"
serde = { version = "1", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }
+3 -3
View File
@@ -177,7 +177,7 @@ impl<T: 'static> Signal<T> {
} else if let Some(current_scope_id) = current_scope_id() { } else if let Some(current_scope_id) = current_scope_id() {
// only subscribe if the vdom is rendering // only subscribe if the vdom is rendering
if dioxus_core::vdom_is_rendering() { if dioxus_core::vdom_is_rendering() {
log::trace!( tracing::trace!(
"{:?} subscribed to {:?}", "{:?} subscribed to {:?}",
self.inner.value, self.inner.value,
current_scope_id current_scope_id
@@ -209,7 +209,7 @@ impl<T: 'static> Signal<T> {
{ {
let inner = self.inner.read(); let inner = self.inner.read();
for &scope_id in &*inner.subscribers.borrow() { for &scope_id in &*inner.subscribers.borrow() {
log::trace!( tracing::trace!(
"Write on {:?} triggered update on {:?}", "Write on {:?} triggered update on {:?}",
self.inner.value, self.inner.value,
scope_id scope_id
@@ -224,7 +224,7 @@ impl<T: 'static> Signal<T> {
std::mem::take(&mut *effects) std::mem::take(&mut *effects)
}; };
for effect in subscribers { for effect in subscribers {
log::trace!( tracing::trace!(
"Write on {:?} triggered effect {:?}", "Write on {:?} triggered effect {:?}",
self.inner.value, self.inner.value,
effect effect
+2 -2
View File
@@ -15,14 +15,14 @@ askama_escape = "0.10.3"
thiserror = "1.0.23" thiserror = "1.0.23"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
lru = "0.10.0" lru = "0.10.0"
log = "0.4.13" tracing = { workspace = true }
http = "0.2.9" http = "0.2.9"
tokio = { version = "1.28", features = ["full"], optional = true } tokio = { version = "1.28", features = ["full"], optional = true }
[dev-dependencies] [dev-dependencies]
dioxus = { workspace = true } dioxus = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
log = { workspace = true } tracing = { workspace = true }
fern = { version = "0.6.0", features = ["colored"] } fern = { version = "0.6.0", features = ["colored"] }
anyhow = "1.0" anyhow = "1.0"
argh = "0.1.4" argh = "0.1.4"
+5 -5
View File
@@ -139,13 +139,13 @@ impl IncrementalRenderer {
let age = elapsed.as_secs(); let age = elapsed.as_secs();
if let Some(invalidate_after) = self.invalidate_after { if let Some(invalidate_after) = self.invalidate_after {
if elapsed < invalidate_after { if elapsed < invalidate_after {
log::trace!("memory cache hit {:?}", route); tracing::trace!("memory cache hit {:?}", route);
output.write_all(cache_hit).await?; output.write_all(cache_hit).await?;
let max_age = invalidate_after.as_secs(); let max_age = invalidate_after.as_secs();
return Ok(Some(RenderFreshness::new(age, max_age))); return Ok(Some(RenderFreshness::new(age, max_age)));
} }
} else { } else {
log::trace!("memory cache hit {:?}", route); tracing::trace!("memory cache hit {:?}", route);
output.write_all(cache_hit).await?; output.write_all(cache_hit).await?;
return Ok(Some(RenderFreshness::new_age(age))); return Ok(Some(RenderFreshness::new_age(age)));
} }
@@ -157,7 +157,7 @@ impl IncrementalRenderer {
if let Ok(file) = tokio::fs::File::open(file_path.full_path).await { if let Ok(file) = tokio::fs::File::open(file_path.full_path).await {
let mut file = BufReader::new(file); let mut file = BufReader::new(file);
tokio::io::copy_buf(&mut file, output).await?; tokio::io::copy_buf(&mut file, output).await?;
log::trace!("file cache hit {:?}", route); tracing::trace!("file cache hit {:?}", route);
self.promote_memory_cache(&route); self.promote_memory_cache(&route);
return Ok(Some(freshness)); return Ok(Some(freshness));
} }
@@ -184,7 +184,7 @@ impl IncrementalRenderer {
let freshness = self let freshness = self
.render_and_cache(route, component, props, output, rebuild_with, renderer) .render_and_cache(route, component, props, output, rebuild_with, renderer)
.await?; .await?;
log::trace!("cache miss"); tracing::trace!("cache miss");
Ok(freshness) Ok(freshness)
} }
} }
@@ -206,7 +206,7 @@ impl IncrementalRenderer {
} }
// if the timestamp is invalid or passed, delete the file // if the timestamp is invalid or passed, delete the file
if let Err(err) = std::fs::remove_file(entry.path()) { if let Err(err) = std::fs::remove_file(entry.path()) {
log::error!("Failed to remove file: {}", err); tracing::error!("Failed to remove file: {}", err);
} }
} }
} }
+1
View File
@@ -20,6 +20,7 @@ dioxus-interpreter-js = { workspace = true, features = [
js-sys = "0.3.56" js-sys = "0.3.56"
wasm-bindgen = { workspace = true, features = ["enable-interning"] } wasm-bindgen = { workspace = true, features = ["enable-interning"] }
wasm-bindgen-futures = "0.4.29" wasm-bindgen-futures = "0.4.29"
tracing = { workspace = true }
log = { workspace = true } log = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
console_error_panic_hook = { version = "0.1.7", optional = true } console_error_panic_hook = { version = "0.1.7", optional = true }
+1 -1
View File
@@ -49,7 +49,7 @@ fn main() {
let _ = dom.rebuild(); let _ = dom.rebuild();
let pre = dioxus_ssr::pre_render(&dom); let pre = dioxus_ssr::pre_render(&dom);
log::trace!("{}", pre); tracing::trace!("{}", pre);
// set the inner content of main to the pre-rendered content // set the inner content of main to the pre-rendered content
window() window()
+1 -1
View File
@@ -249,7 +249,7 @@ impl WebsysDom {
for id in to_mount { for id in to_mount {
let node = get_node(id.0 as u32); let node = get_node(id.0 as u32);
if let Some(element) = node.dyn_ref::<Element>() { if let Some(element) = node.dyn_ref::<Element>() {
log::info!("mounted event fired: {}", id.0); tracing::info!("mounted event fired: {}", id.0);
let data: MountedData = element.into(); let data: MountedData = element.into();
let data = Rc::new(data); let data = Rc::new(data);
let _ = self.event_channel.unbounded_send(UiEvent { let _ = self.event_channel.unbounded_send(UiEvent {
+1 -1
View File
@@ -46,7 +46,7 @@ impl WebEvaluator {
Ok(data) => _ = channel_sender.send_blocking(data), Ok(data) => _ = channel_sender.send_blocking(data),
Err(e) => { Err(e) => {
// Can't really do much here. // Can't really do much here.
log::error!("failed to serialize JsValue to serde_json::Value (eval communication) - {}", e); tracing::error!("failed to serialize JsValue to serde_json::Value (eval communication) - {}", e);
} }
} }
}); });
+4 -4
View File
@@ -170,7 +170,7 @@ pub fn launch_with_props<T: 'static>(
/// } /// }
/// ``` /// ```
pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_props: T, cfg: Config) { pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_props: T, cfg: Config) {
log::info!("Starting up"); tracing::info!("Starting up");
let mut dom = VirtualDom::new_with_props(root, root_props); let mut dom = VirtualDom::new_with_props(root, root_props);
@@ -205,7 +205,7 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
let mut websys_dom = dom::WebsysDom::new(cfg, tx); let mut websys_dom = dom::WebsysDom::new(cfg, tx);
log::info!("rebuilding app"); tracing::info!("rebuilding app");
if should_hydrate { if should_hydrate {
#[cfg(feature = "hydrate")] #[cfg(feature = "hydrate")]
@@ -217,7 +217,7 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
websys_dom.load_templates(&templates); websys_dom.load_templates(&templates);
if let Err(err) = websys_dom.rehydrate(&dom) { if let Err(err) = websys_dom.rehydrate(&dom) {
log::error!( tracing::error!(
"Rehydration failed {:?}. Rebuild DOM into element from scratch", "Rehydration failed {:?}. Rebuild DOM into element from scratch",
&err &err
); );
@@ -240,7 +240,7 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
websys_dom.mount(); websys_dom.mount();
loop { loop {
log::trace!("waiting for work"); tracing::trace!("waiting for work");
// if virtualdom has nothing, wait for it to have something before requesting idle time // if virtualdom has nothing, wait for it to have something before requesting idle time
// if there is work then this future resolves immediately. // if there is work then this future resolves immediately.
+4 -4
View File
@@ -114,9 +114,9 @@ impl WebsysDom {
node: &TemplateNode, node: &TemplateNode,
last_node_was_static_text: &mut bool, last_node_was_static_text: &mut bool,
) -> Result<(), RehydrationError> { ) -> Result<(), RehydrationError> {
log::trace!("rehydrate template node: {:?}", node); tracing::trace!("rehydrate template node: {:?}", node);
if let Ok(current_child) = current_child { if let Ok(current_child) = current_child {
if log::log_enabled!(log::Level::Trace) { if tracing::event_enabled!(tracing::Level::TRACE) {
web_sys::console::log_1(&current_child.clone().into()); web_sys::console::log_1(&current_child.clone().into());
} }
} }
@@ -203,9 +203,9 @@ impl WebsysDom {
dynamic: &DynamicNode, dynamic: &DynamicNode,
last_node_was_static_text: &mut bool, last_node_was_static_text: &mut bool,
) -> Result<(), RehydrationError> { ) -> Result<(), RehydrationError> {
log::trace!("rehydrate dynamic node: {:?}", dynamic); tracing::trace!("rehydrate dynamic node: {:?}", dynamic);
if let Ok(current_child) = current_child { if let Ok(current_child) = current_child {
if log::log_enabled!(log::Level::Trace) { if tracing::event_enabled!(tracing::Level::TRACE) {
web_sys::console::log_1(&current_child.clone().into()); web_sys::console::log_1(&current_child.clone().into());
} }
} }