Skip to content

Commit

Permalink
feat: integrate dioxus-logger inline (#3302)
Browse files Browse the repository at this point in the history
* feat: integrate dioxus-logger inline

* remove log/simple logger references

* fix: add dioxus-data-id-0 to root elements to not emit errors internally

* drop config.toml and use cargo.toml profiles instead

* make clippy happy with the unit value lint

* feat: better presentation for logging
  • Loading branch information
jkelleyrtp authored Dec 7, 2024
1 parent 995a529 commit 7d490dc
Show file tree
Hide file tree
Showing 36 changed files with 255 additions and 169 deletions.
14 changes: 0 additions & 14 deletions .cargo/config.toml

This file was deleted.

64 changes: 7 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 20 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ members = [
"packages/const-serialize",
"packages/const-serialize-macro",
"packages/dx-wire-format",
"packages/logger",

# Playwright tests
"packages/playwright-tests/liveview",
Expand Down Expand Up @@ -138,7 +139,7 @@ dioxus-devtools-types = { path = "packages/devtools-types", version = "0.6.0-rc.
dioxus-fullstack = { path = "packages/fullstack", version = "0.6.0-rc.0" }
dioxus_server_macro = { path = "packages/server-macro", version = "0.6.0-rc.0", default-features = false }
dioxus-dx-wire-format = { path = "packages/dx-wire-format", version = "0.6.0-rc.0" }

dioxus-logger = { path = "packages/logger", version = "0.6.0-rc.0" }
const-serialize = { path = "packages/const-serialize", version = "0.6.0-rc.0" }
const-serialize-macro = { path = "packages/const-serialize-macro", version = "0.6.0-rc.0" }
generational-box = { path = "packages/generational-box", version = "0.6.0-rc.0" }
Expand All @@ -157,10 +158,12 @@ clap = { version = "4.5.7" }
askama_escape = "0.10.3"
tracing = "0.1.37"
tracing-futures = "0.2.5"
tracing-subscriber = { version = "0.3.18", default-features = false }
toml = "0.8"
tokio = "1.40"
slab = "0.4.2"
slotmap = { version = "1.0.7", features = ["serde"] }
futures = "0.3.30"
futures-channel = "0.3.21"
futures-util = { version = "0.3", default-features = false }
rustc-hash = "1.1.0"
Expand Down Expand Up @@ -207,7 +210,6 @@ fluent-uri = { version = "0.2.0", features = ["serde"] }
internment = { version = "0.7.0" }
proc-macro2-diagnostics = { version = "0.10", default-features = false }
env_logger = "0.11.0"
tracing-subscriber = "0.3.17"
chrono = { version = "0.4.34" }
gloo = { version = "0.8.0" }
gloo-utils = { version = "0.1.6" }
Expand All @@ -222,6 +224,8 @@ cargo-config2 = "0.1.26"
criterion = { version = "0.5" }
walrus = "0.23.2"
cargo_metadata = "0.18.1"
tracing-wasm = "0.2.1"
console_error_panic_hook = "0.1.7"

# desktop
wry = { version = "0.45.0", default-features = false }
Expand Down Expand Up @@ -260,6 +264,16 @@ inherits = "dev"
debug-assertions = false
incremental = true

[profile.wasm-dev]
inherits = "dev"
opt-level = 1

[profile.server-dev]
inherits = "dev"

[profile.android-dev]
inherits = "dev"

# This is a "virtual package"
# It is not meant to be published, but is used so "cargo run --example XYZ" works properly
[package]
Expand Down Expand Up @@ -473,3 +487,7 @@ doc-scrape-examples = true
[[example]]
name = "eval"
doc-scrape-examples = true

[[example]]
name = "logging"
doc-scrape-examples = true
4 changes: 0 additions & 4 deletions example-projects/file-explorer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ publish = false

[dependencies]
dioxus = { workspace = true, features = ["desktop"] }

# Debug
log = "0.4.19"
dioxus-logger = "0.4.1"
open = "5.1.2"
3 changes: 0 additions & 3 deletions example-projects/fullstack-hackernews/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ dioxus = { workspace = true, features = ["fullstack", "router"] }
chrono = { version = "0.4.38", features = ["serde"] }
reqwest = { workspace= true, features = ["json"] }
serde = { workspace = true, features = ["derive"] }
tracing-wasm = "0.2.1"
tracing = { workspace = true }
tracing-subscriber = "0.3.17"

[features]
default = []
Expand Down
6 changes: 0 additions & 6 deletions example-projects/fullstack-hackernews/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ use std::{
use svg_attributes::to;

fn main() {
#[cfg(feature = "web")]
tracing_wasm::set_as_global_default();

#[cfg(feature = "server")]
tracing_subscriber::fmt::init();

LaunchBuilder::new()
.with_cfg(server_only! {
dioxus::fullstack::ServeConfig::builder().enable_out_of_order_streaming()
Expand Down
3 changes: 1 addition & 2 deletions examples/fullstack-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dioxus-fullstack = { workspace = true }
axum = { workspace = true, optional = true }
tokio = { workspace = true, features = ["full"], optional = true }
tower-http = { workspace = true, features = ["auth"], optional = true }
simple_logger = { version = "4.2.0", optional = true }
async-trait = { version = "0.1.71", optional = true }
sqlx = { version = "0.7.0", features = [
"macros",
Expand Down Expand Up @@ -44,5 +43,5 @@ optional = true

[features]
default = []
server = ["axum", "tokio", "dioxus-fullstack/axum", "tower-http", "simple_logger", "async-trait", "sqlx", "axum_session", "axum_session_auth", "http", "tower"]
server = ["axum", "tokio", "dioxus-fullstack/axum", "tower-http", "async-trait", "sqlx", "axum_session", "axum_session_auth", "http", "tower"]
web = ["dioxus-web"]
4 changes: 3 additions & 1 deletion examples/fullstack-auth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ use dioxus_fullstack::prelude::*;
use serde::{Deserialize, Serialize};

fn main() {
// Set the logger ahead of time since we don't use `dioxus::launch` on the server
dioxus::logger::initialize_default();

#[cfg(feature = "web")]
// Hydrate the application on the client
dioxus_web::launch::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
Expand All @@ -27,7 +30,6 @@ fn main() {
use axum_session::SessionStore;
use axum_session_auth::AuthConfig;
use axum_session_auth::SessionSqlitePool;
simple_logger::SimpleLogger::new().init().unwrap();
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
Expand Down
4 changes: 0 additions & 4 deletions examples/fullstack-hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ publish = false
[dependencies]
dioxus = { workspace = true, features = ["fullstack"]}
serde = "1.0.159"
simple_logger = "4.2.0"
tracing-wasm = "0.2.1"
tracing = { workspace = true }
tracing-subscriber = "0.3.17"
reqwest = { workspace = true }

[features]
Expand Down
6 changes: 0 additions & 6 deletions examples/fullstack-hello-world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,5 @@ async fn get_server_data() -> Result<String, ServerFnError> {
}

fn main() {
#[cfg(feature = "web")]
tracing_wasm::set_as_global_default();

#[cfg(feature = "server")]
tracing_subscriber::fmt::init();

dioxus::launch(app);
}
10 changes: 3 additions & 7 deletions examples/fullstack-streaming/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ publish = false

[dependencies]
dioxus = { workspace = true, features = ["fullstack"] }
serde = "1.0.159"
simple_logger = "4.2.0"
tracing-wasm = "0.2.1"
tracing.workspace = true
tracing-subscriber = "0.3.17"
futures = "0.3.30"
serde = { workspace = true }
futures = { workspace = true }
tokio = { workspace = true, optional = true }
futures-util.workspace = true
once_cell = "1.19.0"
once_cell = { workspace = true }

[features]
default = []
Expand Down
1 change: 1 addition & 0 deletions examples/fullstack-streaming/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub async fn test_stream() -> Result<TextStream, ServerFnError> {
tokio::spawn(async move {
loop {
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
dioxus::logger::tracing::info!("Sending new chunk!");
let _ = tx.unbounded_send(Ok("Hello, world!".to_string()));
}
});
Expand Down
Loading

0 comments on commit 7d490dc

Please sign in to comment.