mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
switch to tracing for logging
This commit is contained in:
parent
c8127e164b
commit
c55c17cb81
50 changed files with 95 additions and 78 deletions
|
@ -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_server_macro = { path = "packages/server-macro", version = "0.4.1" }
|
||||
log = "0.4.19"
|
||||
tracing = "0.1.37"
|
||||
tracing-futures = "0.2.5"
|
||||
tokio = "1.28"
|
||||
slab = "0.4.2"
|
||||
futures-channel = "0.3.21"
|
||||
|
|
|
@ -28,7 +28,7 @@ slab = { workspace = true }
|
|||
futures-channel = { workspace = true }
|
||||
|
||||
smallbox = "0.8.1"
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
|
||||
# Serialize the Edits for use in Webview/Liveview instances
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
|
|
|
@ -68,7 +68,7 @@ unsafe impl<'a, P> AnyProps<'a> for VProps<'a, P> {
|
|||
Ok(None) => RenderReturn::default(),
|
||||
Err(err) => {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,8 @@ impl<'b> VirtualDom {
|
|||
right.scope.set(Some(scope_id));
|
||||
|
||||
// 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> = 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
|
||||
// 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()) } {
|
||||
tracing::trace!(
|
||||
"Memoized props for component {:#?} ({})",
|
||||
scope_id,
|
||||
old_scope.context().name
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
|
|||
///
|
||||
/// ```rust, ignore
|
||||
/// rsx!{
|
||||
/// MyComponent { onclick: move |evt| log::info!("clicked") }
|
||||
/// MyComponent { onclick: move |evt| tracing::debug!("clicked") }
|
||||
/// }
|
||||
///
|
||||
/// #[derive(Props)]
|
||||
|
|
|
@ -64,6 +64,7 @@ impl VirtualDom {
|
|||
let props: &dyn AnyProps = scope.props.as_ref().unwrap().as_ref();
|
||||
let props: &dyn AnyProps = std::mem::transmute(props);
|
||||
|
||||
let _span = tracing::trace_span!("render", scope = %scope.context().name);
|
||||
props.render(scope).extend_lifetime()
|
||||
};
|
||||
|
||||
|
|
|
@ -306,6 +306,7 @@ impl VirtualDom {
|
|||
pub fn mark_dirty(&mut self, id: ScopeId) {
|
||||
if let Some(scope) = self.get_scope(id) {
|
||||
let height = scope.height();
|
||||
tracing::trace!("Marking scope {:?} ({}) as dirty", id, scope.context().name);
|
||||
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
|
||||
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();
|
||||
placeholder.id.set(Some(id));
|
||||
self.mutations.push(Mutation::CreatePlaceholder { id });
|
||||
|
|
|
@ -18,7 +18,7 @@ dioxus-hot-reload = { workspace = true, optional = true }
|
|||
serde = "1.0.136"
|
||||
serde_json = "1.0.79"
|
||||
thiserror = { workspace = true }
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
wry = { version = "0.28.0" }
|
||||
futures-channel = { workspace = true }
|
||||
tokio = { workspace = true, features = [
|
||||
|
|
|
@ -194,7 +194,7 @@ impl DesktopService {
|
|||
/// launch print modal
|
||||
pub fn print(&self) {
|
||||
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();
|
||||
|
||||
#[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.
|
||||
|
|
|
@ -330,7 +330,7 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
|
|||
if temp.contains_key("href") {
|
||||
let open = webbrowser::open(temp["href"].as_str().unwrap());
|
||||
if let Err(e) = open {
|
||||
log::error!("Open Browser error: {:?}", e);
|
||||
tracing::error!("Open Browser error: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ impl QueryEngine {
|
|||
}})
|
||||
}})();"#
|
||||
)) {
|
||||
log::warn!("Query error: {err}");
|
||||
tracing::warn!("Query error: {err}");
|
||||
}
|
||||
|
||||
Query {
|
||||
|
|
|
@ -30,7 +30,7 @@ hot-reload = ["dioxus-hot-reload"]
|
|||
|
||||
[dev-dependencies]
|
||||
futures-util = { workspace = true }
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
rand = { version = "0.8.4", features = ["small_rng"] }
|
||||
criterion = "0.3.5"
|
||||
thiserror = { workspace = true }
|
||||
|
|
|
@ -14,7 +14,7 @@ keywords = ["dom", "ui", "gui", "react", "state-management"]
|
|||
[dependencies]
|
||||
dioxus-core = { workspace = true }
|
||||
im-rc = { version = "15.0.0", features = ["serde"] }
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
closure = "0.3.0"
|
||||
|
|
|
@ -66,14 +66,14 @@ impl AtomRoot {
|
|||
|
||||
if let Some(slot) = atoms.get_mut(&ptr) {
|
||||
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 {
|
||||
log::trace!("updating subcsriber");
|
||||
tracing::trace!("updating subcsriber");
|
||||
(self.update_any)(*scope);
|
||||
}
|
||||
} else {
|
||||
log::trace!("no atoms found for {:?}", ptr);
|
||||
tracing::trace!("no atoms found for {:?}", ptr);
|
||||
atoms.insert(
|
||||
ptr,
|
||||
Slot {
|
||||
|
@ -96,7 +96,7 @@ impl AtomRoot {
|
|||
pub fn force_update(&self, ptr: AtomId) {
|
||||
if let Some(slot) = self.atoms.borrow_mut().get(&ptr) {
|
||||
for scope in slot.subscribers.iter() {
|
||||
log::trace!("updating subcsriber");
|
||||
tracing::trace!("updating subcsriber");
|
||||
(self.update_any)(*scope);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ dioxus-desktop = { workspace = true, optional = true }
|
|||
# Router Integration
|
||||
dioxus-router = { workspace = true, optional = true }
|
||||
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tracing-futures = { workspace = true }
|
||||
once_cell = "1.17.1"
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true, features = ["full"], optional = true }
|
||||
|
|
|
@ -66,7 +66,7 @@ async fn get_server_data() -> Result<String, ServerFnError> {
|
|||
|
||||
fn main() {
|
||||
#[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")]
|
||||
simple_logger::SimpleLogger::new().init().unwrap();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ async fn get_server_data() -> Result<String, ServerFnError> {
|
|||
|
||||
fn main() {
|
||||
#[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")]
|
||||
simple_logger::SimpleLogger::new().init().unwrap();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ async fn get_server_data() -> Result<String, ServerFnError> {
|
|||
|
||||
fn main() {
|
||||
#[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")]
|
||||
simple_logger::SimpleLogger::new().init().unwrap();
|
||||
|
||||
|
|
|
@ -389,7 +389,7 @@ pub async fn render_handler<P: Clone + serde::Serialize + Send + Sync + 'static>
|
|||
response
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to render page: {}", e);
|
||||
tracing::error!("Failed to render page: {}", e);
|
||||
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());
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("Error rendering SSR: {}", err);
|
||||
tracing::error!("Error rendering SSR: {}", err);
|
||||
res.write_body("Error rendering SSR").unwrap();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -84,7 +84,7 @@ use warp::{
|
|||
/// async move {
|
||||
/// let req = warp::hyper::Request::from_parts(parts, bytes.into());
|
||||
/// service.run(req).await.map_err(|err| {
|
||||
/// log::error!("Server function error: {}", err);
|
||||
/// tracing::error!("Server function error: {}", err);
|
||||
/// warp::reject::reject()
|
||||
/// })
|
||||
/// }
|
||||
|
@ -142,7 +142,7 @@ pub fn register_server_fns(server_fn_route: &'static str) -> BoxedFilter<(impl R
|
|||
async move {
|
||||
let req = warp::hyper::Request::from_parts(parts, bytes.into());
|
||||
service.run(req).await.map_err(|err| {
|
||||
log::error!("Server function error: {}", err);
|
||||
tracing::error!("Server function error: {}", err);
|
||||
warp::reject::reject()
|
||||
})
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ pub fn render_ssr<P: Clone + serde::Serialize + Send + Sync + 'static>(
|
|||
res
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("Failed to render ssr: {}", err);
|
||||
tracing::error!("Failed to render ssr: {}", err);
|
||||
Response::builder()
|
||||
.status(500)
|
||||
.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 sc = crate::prelude::server_context();
|
||||
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
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ where
|
|||
if first_run {
|
||||
match crate::html_storage::deserialize::take_server_data() {
|
||||
Some(data) => {
|
||||
log::trace!("Loaded {data:?} from server");
|
||||
tracing::trace!("Loaded {data:?} from server");
|
||||
*state.value.borrow_mut() = Some(Box::new(data));
|
||||
state.needs_regen.set(false);
|
||||
return Some(state);
|
||||
}
|
||||
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;
|
||||
if first_run {
|
||||
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 {
|
||||
#[cfg(feature = "ssr")]
|
||||
{
|
||||
log::trace!("Suspending first run of use_server_future");
|
||||
tracing::trace!("Suspending first run of use_server_future");
|
||||
cx.suspend();
|
||||
}
|
||||
None
|
||||
|
|
|
@ -30,7 +30,7 @@ impl Default for HotReloadState {
|
|||
}
|
||||
|
||||
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 => {
|
||||
|
|
|
@ -10,7 +10,7 @@ pub(crate) fn serde_from_bytes<T: DeserializeOwned>(string: &[u8]) -> Option<T>
|
|||
let decompressed = match STANDARD.decode(string) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(err) => {
|
||||
log::error!("Failed to decode base64: {}", err);
|
||||
tracing::error!("Failed to decode base64: {}", err);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ pub(crate) fn serde_from_bytes<T: DeserializeOwned>(string: &[u8]) -> Option<T>
|
|||
match postcard::from_bytes(&decompressed) {
|
||||
Ok(data) => Some(data),
|
||||
Err(err) => {
|
||||
log::error!("Failed to deserialize: {}", err);
|
||||
tracing::error!("Failed to deserialize: {}", err);
|
||||
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") {
|
||||
Some(element) => element,
|
||||
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;
|
||||
}
|
||||
};
|
||||
let attribute = match element.get_attribute("data-serialized") {
|
||||
Some(attribute) => attribute,
|
||||
None => {
|
||||
log::error!("Failed to get attribute: data-serialized");
|
||||
tracing::error!("Failed to get attribute: data-serialized");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ impl HTMLDataCursor {
|
|||
pub fn take<T: DeserializeOwned>(&self) -> Option<T> {
|
||||
let current = self.index.load(std::sync::atomic::Ordering::SeqCst);
|
||||
if current >= self.data.len() {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Tried to take more data than was available, len: {}, index: {}",
|
||||
self.data.len(),
|
||||
current
|
||||
|
@ -48,7 +48,7 @@ impl HTMLDataCursor {
|
|||
match postcard::from_bytes(cursor) {
|
||||
Ok(x) => Some(x),
|
||||
Err(e) => {
|
||||
log::error!("Error deserializing data: {:?}", e);
|
||||
tracing::error!("Error deserializing data: {:?}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::pin::Pin;
|
||||
use tracing_futures::Instrument;
|
||||
|
||||
use http::{Request, Response};
|
||||
|
||||
|
@ -45,7 +46,11 @@ where
|
|||
> + 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()) })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,10 +50,10 @@ impl SsrRendererPool {
|
|||
let prev_context =
|
||||
SERVER_CONTEXT.with(|ctx| ctx.replace(server_context));
|
||||
// poll the future, which may call server_context()
|
||||
log::info!("Rebuilding vdom");
|
||||
tracing::info!("Rebuilding vdom");
|
||||
let _ = vdom.rebuild();
|
||||
vdom.wait_for_suspense().await;
|
||||
log::info!("Suspense resolved");
|
||||
tracing::info!("Suspense resolved");
|
||||
// after polling the future, we need to restore the context
|
||||
SERVER_CONTEXT.with(|ctx| ctx.replace(prev_context));
|
||||
|
||||
|
@ -116,10 +116,10 @@ impl SsrRendererPool {
|
|||
let prev_context = SERVER_CONTEXT
|
||||
.with(|ctx| ctx.replace(Box::new(server_context)));
|
||||
// poll the future, which may call server_context()
|
||||
log::info!("Rebuilding vdom");
|
||||
tracing::info!("Rebuilding vdom");
|
||||
let _ = vdom.rebuild();
|
||||
vdom.wait_for_suspense().await;
|
||||
log::info!("Suspense resolved");
|
||||
tracing::info!("Suspense resolved");
|
||||
// after polling the future, we need to restore the context
|
||||
SERVER_CONTEXT.with(|ctx| ctx.replace(prev_context));
|
||||
})
|
||||
|
|
|
@ -29,7 +29,7 @@ where
|
|||
.to_string()
|
||||
.parse()
|
||||
.unwrap_or_else(|err| {
|
||||
log::error!("Failed to parse uri: {}", err);
|
||||
tracing::error!("Failed to parse uri: {}", err);
|
||||
"/"
|
||||
.parse()
|
||||
.unwrap_or_else(|err| {
|
||||
|
|
|
@ -16,7 +16,7 @@ nightly-features = []
|
|||
[dependencies]
|
||||
dioxus-core = { workspace = true }
|
||||
futures-channel = { workspace = true }
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
slab = { workspace = true }
|
||||
dioxus-debug-cell = "0.1.1"
|
||||
|
|
|
@ -108,7 +108,7 @@ impl_event! {
|
|||
///
|
||||
/// ## Example
|
||||
/// ```rust, ignore
|
||||
/// rsx!( button { "click me", onclick: move |_| log::info!("Clicked!`") } )
|
||||
/// rsx!( button { "click me", onclick: move |_| tracing::info!("Clicked!`") } )
|
||||
/// ```
|
||||
///
|
||||
/// ## Reference
|
||||
|
|
|
@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
|
|||
|
||||
[dependencies]
|
||||
thiserror = { workspace = true }
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
slab = { workspace = true }
|
||||
futures-util = { workspace = true, default-features = false, features = [
|
||||
"sink",
|
||||
|
|
|
@ -126,7 +126,7 @@ impl QueryEngine {
|
|||
}})
|
||||
}})();"#
|
||||
)) {
|
||||
log::warn!("Query error: {err}");
|
||||
tracing::warn!("Query error: {err}");
|
||||
}
|
||||
|
||||
Query {
|
||||
|
|
|
@ -14,7 +14,7 @@ anyhow = "1.0.66"
|
|||
dioxus = { workspace = true }
|
||||
dioxus-router-macro = { workspace = true }
|
||||
gloo = { version = "0.8.0", optional = true }
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
futures-util = { workspace = true }
|
||||
urlencoding = "2.1.3"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use dioxus::prelude::*;
|
||||
use log::error;
|
||||
use tracing::error;
|
||||
|
||||
use crate::utils::use_router_internal::use_router_internal;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::fmt::Debug;
|
|||
use std::rc::Rc;
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use log::error;
|
||||
use tracing::error;
|
||||
|
||||
use crate::navigation::NavigationTarget;
|
||||
use crate::prelude::Routable;
|
||||
|
|
|
@ -139,7 +139,7 @@ impl<R: Routable> WebHistory<R> {
|
|||
);
|
||||
|
||||
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 state = myself.create_state(current_route);
|
||||
let _ = replace_state_with_url(&myself.history, &state, Some(¤t_url));
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use gloo::{events::EventListener, render::AnimationFrame, utils::window};
|
||||
use log::error;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use tracing::error;
|
||||
use url::Url;
|
||||
use web_sys::{History, ScrollRestoration, Window};
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ where
|
|||
.await?;
|
||||
}
|
||||
Err(e) => {
|
||||
log::info!("@ route: {}", full_path);
|
||||
log::error!("Error pre-caching static route: {}", e);
|
||||
tracing::info!("@ route: {}", full_path);
|
||||
tracing::error!("Error pre-caching static route: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ where
|
|||
match urlencoding::decode(route) {
|
||||
Ok(segment) => T::from_str(&segment),
|
||||
Err(err) => {
|
||||
log::error!("Failed to decode url encoding: {}", err);
|
||||
tracing::error!("Failed to decode url encoding: {}", err);
|
||||
T::from_str(route)
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ where
|
|||
match urlencoding::decode(&segment) {
|
||||
Ok(segment) => write!(f, "{}", segment)?,
|
||||
Err(err) => {
|
||||
log::error!("Failed to decode url encoding: {}", err);
|
||||
tracing::error!("Failed to decode url encoding: {}", err);
|
||||
write!(f, "{}", segment)?
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ edition = "2018"
|
|||
[dependencies]
|
||||
dioxus-core = { workspace = true }
|
||||
generational-box = { workspace = true }
|
||||
log.workspace = true
|
||||
tracing = { workspace = true }
|
||||
simple_logger = "4.2.0"
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ impl<T: 'static> Signal<T> {
|
|||
} else if let Some(current_scope_id) = current_scope_id() {
|
||||
// only subscribe if the vdom is rendering
|
||||
if dioxus_core::vdom_is_rendering() {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"{:?} subscribed to {:?}",
|
||||
self.inner.value,
|
||||
current_scope_id
|
||||
|
@ -209,7 +209,7 @@ impl<T: 'static> Signal<T> {
|
|||
{
|
||||
let inner = self.inner.read();
|
||||
for &scope_id in &*inner.subscribers.borrow() {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"Write on {:?} triggered update on {:?}",
|
||||
self.inner.value,
|
||||
scope_id
|
||||
|
@ -224,7 +224,7 @@ impl<T: 'static> Signal<T> {
|
|||
std::mem::take(&mut *effects)
|
||||
};
|
||||
for effect in subscribers {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"Write on {:?} triggered effect {:?}",
|
||||
self.inner.value,
|
||||
effect
|
||||
|
|
|
@ -15,14 +15,14 @@ askama_escape = "0.10.3"
|
|||
thiserror = "1.0.23"
|
||||
rustc-hash = "1.1.0"
|
||||
lru = "0.10.0"
|
||||
log = "0.4.13"
|
||||
tracing = { workspace = true }
|
||||
http = "0.2.9"
|
||||
tokio = { version = "1.28", features = ["full"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
dioxus = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
log = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
fern = { version = "0.6.0", features = ["colored"] }
|
||||
anyhow = "1.0"
|
||||
argh = "0.1.4"
|
||||
|
|
|
@ -139,13 +139,13 @@ impl IncrementalRenderer {
|
|||
let age = elapsed.as_secs();
|
||||
if let Some(invalidate_after) = self.invalidate_after {
|
||||
if elapsed < invalidate_after {
|
||||
log::trace!("memory cache hit {:?}", route);
|
||||
tracing::trace!("memory cache hit {:?}", route);
|
||||
output.write_all(cache_hit).await?;
|
||||
let max_age = invalidate_after.as_secs();
|
||||
return Ok(Some(RenderFreshness::new(age, max_age)));
|
||||
}
|
||||
} else {
|
||||
log::trace!("memory cache hit {:?}", route);
|
||||
tracing::trace!("memory cache hit {:?}", route);
|
||||
output.write_all(cache_hit).await?;
|
||||
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 {
|
||||
let mut file = BufReader::new(file);
|
||||
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);
|
||||
return Ok(Some(freshness));
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ impl IncrementalRenderer {
|
|||
let freshness = self
|
||||
.render_and_cache(route, component, props, output, rebuild_with, renderer)
|
||||
.await?;
|
||||
log::trace!("cache miss");
|
||||
tracing::trace!("cache miss");
|
||||
Ok(freshness)
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ impl IncrementalRenderer {
|
|||
}
|
||||
// if the timestamp is invalid or passed, delete the file
|
||||
if let Err(err) = std::fs::remove_file(entry.path()) {
|
||||
log::error!("Failed to remove file: {}", err);
|
||||
tracing::error!("Failed to remove file: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ dioxus-interpreter-js = { workspace = true, features = [
|
|||
js-sys = "0.3.56"
|
||||
wasm-bindgen = { workspace = true, features = ["enable-interning"] }
|
||||
wasm-bindgen-futures = "0.4.29"
|
||||
tracing = { workspace = true }
|
||||
log = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||
|
|
|
@ -49,7 +49,7 @@ fn main() {
|
|||
let _ = dom.rebuild();
|
||||
|
||||
let pre = dioxus_ssr::pre_render(&dom);
|
||||
log::trace!("{}", pre);
|
||||
tracing::trace!("{}", pre);
|
||||
|
||||
// set the inner content of main to the pre-rendered content
|
||||
window()
|
||||
|
|
|
@ -249,7 +249,7 @@ impl WebsysDom {
|
|||
for id in to_mount {
|
||||
let node = get_node(id.0 as u32);
|
||||
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 = Rc::new(data);
|
||||
let _ = self.event_channel.unbounded_send(UiEvent {
|
||||
|
|
|
@ -46,7 +46,7 @@ impl WebEvaluator {
|
|||
Ok(data) => _ = channel_sender.send_blocking(data),
|
||||
Err(e) => {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
log::info!("Starting up");
|
||||
tracing::info!("Starting up");
|
||||
|
||||
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);
|
||||
|
||||
log::info!("rebuilding app");
|
||||
tracing::info!("rebuilding app");
|
||||
|
||||
if should_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);
|
||||
|
||||
if let Err(err) = websys_dom.rehydrate(&dom) {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Rehydration failed {:?}. Rebuild DOM into element from scratch",
|
||||
&err
|
||||
);
|
||||
|
@ -240,7 +240,7 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
|
|||
websys_dom.mount();
|
||||
|
||||
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 there is work then this future resolves immediately.
|
||||
|
|
|
@ -114,9 +114,9 @@ impl WebsysDom {
|
|||
node: &TemplateNode,
|
||||
last_node_was_static_text: &mut bool,
|
||||
) -> Result<(), RehydrationError> {
|
||||
log::trace!("rehydrate template node: {:?}", node);
|
||||
tracing::trace!("rehydrate template node: {:?}", node);
|
||||
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(¤t_child.clone().into());
|
||||
}
|
||||
}
|
||||
|
@ -203,9 +203,9 @@ impl WebsysDom {
|
|||
dynamic: &DynamicNode,
|
||||
last_node_was_static_text: &mut bool,
|
||||
) -> Result<(), RehydrationError> {
|
||||
log::trace!("rehydrate dynamic node: {:?}", dynamic);
|
||||
tracing::trace!("rehydrate dynamic node: {:?}", dynamic);
|
||||
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(¤t_child.clone().into());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue