#logging #dioxus #info #launch #component #init #rendered #react

dioxus-logger

A logging utility to provide a standard interface whether you're targeting web desktop, fullstack, and more

13 unstable releases (6 breaking)

0.7.0-alpha.0 May 14, 2025
0.6.2 Jan 22, 2025
0.6.1 Dec 18, 2024
0.5.1 May 13, 2024
0.3.0 Nov 10, 2022

#181 in Debugging

Download history 4072/week @ 2025-02-01 4860/week @ 2025-02-08 4475/week @ 2025-02-15 5527/week @ 2025-02-22 4608/week @ 2025-03-01 5176/week @ 2025-03-08 5703/week @ 2025-03-15 5526/week @ 2025-03-22 5090/week @ 2025-03-29 5849/week @ 2025-04-05 5265/week @ 2025-04-12 4891/week @ 2025-04-19 6362/week @ 2025-04-26 5550/week @ 2025-05-03 5129/week @ 2025-05-10 4144/week @ 2025-05-17

22,266 downloads per month
Used in 10 crates

MIT license

23KB
182 lines

📡 Dioxus Logger 🛰️

A logging utility to provide a standard interface whether you're targeting web, desktop, fullstack, and more.


dioxus-logger is a basic cross-platform facade for logging in Dioxus that uses the tracing crate.

use dioxus::prelude::*;
use dioxus_logger::tracing::{Level, info};

fn main() {
  dioxus_logger::init(Level::INFO).expect("logger failed to init");
  dioxus::launch(App);
}

#[component]
fn App() -> Element {
  info!("App rendered");
  rsx! {
    p { "hi" }
  }
}

Dioxus support

As of v0.6, dioxus_logger is part of dioxus itself. Dioxus will call init with a default Level, though you can still override the default with init.

use dioxus::prelude::*;
use dioxus::logger::tracing::{Level, info};

fn main() {
  dioxus::logger::init(Level::INFO).expect("logger failed to init");
  dioxus::launch(App);
}

#[component]
fn App() -> Element {
  info!("App rendered");
  rsx! {
    p { "hi" }
  }
}

For non-wasm targets, runtime filtering is based on the RUST_LOG environment variable. e.g. for RUST_LOG=none,crateName=trace only logs trace and above for crateName will be captured. See here for syntax. For crates with - in the name, these need to be changed to _ in RUST_LOG.

Platform Support

Dioxus logger will eventually support every target that Dioxus does. Currently mobile and TUI are not supported.

Installation

dioxus_logger is part of Dioxus v0.6. If you're using Dioxus v0.6, then no installation is required!

If you're on Dioxus v0.5 and below, you can add dioxus-logger to your application by adding it to your dependencies.

[dependencies]
dioxus-logger = "0.5"

License

This project is licensed under the MIT license.

Every contribution intentionally submitted for inclusion in dioxus-logger by you, shall be licensed as MIT, without any additional terms or conditions.

Dependencies

~4–5.5MB
~92K SLoC