feat: integrate dioxus-logger inline (#3302)

* 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
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-12-06 16:27:05 -08:00
1 parent 995a529b2f
commit 7d490dc3bd
36 files changed
+255 -169

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
//! Dioxus ships out-of-the-box with tracing hooks that integrate with the Dioxus-CLI.
//!
//! The built-in tracing-subscriber automatically sets up a wasm panic hook and wires up output
//! to be consumed in a machine-readable format when running under `dx`.
//!
//! You can disable the built-in tracing-subscriber or customize the log level yourself.
//!
//! By default:
//! - in `dev` mode, the default log output is `debug`
//! - in `release` mode, the default log output is `info`
//!
//! To use the dioxus logger in your app, simply call any of the tracing functions (info!(), warn!(), error!())
use dioxus::logger::tracing::{debug, error, info, warn};
use dioxus::prelude::*;
fn main() {
dioxus::launch(app);
}
fn app() -> Element {
rsx! {
div {
h1 { "Logger demo" }
button {
onclick: move |_| warn!("Here's a warning!"),
"Warn!"
}
button {
onclick: move |_| error!("Here's an error!"),
"Error!"
}
button {
onclick: move |_| debug!("Here's a debug"),
"Debug!"
}
button {
onclick: move |_| info!("Here's an info!"),
"Info!"
}
}
}
}