Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate dioxus-logger inline #3302

Merged
merged 7 commits into from
Dec 7, 2024
Merged

Conversation

jkelleyrtp
Copy link
Member

@jkelleyrtp jkelleyrtp commented Dec 6, 2024

Inlines dioxus-logger so we can add better CLI support to it during the 0.6 release cycle.

Also cuts down on the verbosity of setting up logging in all of our examples.

This PR adds a new method to the logger:

pub fn initialize_default() {
     if tracing::dispatcher::has_been_set() {
         return;
     }

     if cfg!(debug_assertions) {
         _ = init(Level::DEBUG);
     } else {
         _ = init(Level::INFO);
     }
 }

The new method is basically "set up the logger the way dioxus would set up the logger".

This way, if you're doing custom logging setups, you can simply put ours first:

use dioxus::prelude::*;
use tracing::info;

fn main() {
    dioxus::logger::initialize_default();

    info!("Doing some work before launching...");

    dioxus::launch(App);
}

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

We should eventually add a function that builds our custom logging layer in case people want to extend our layer with their layer.

@jkelleyrtp jkelleyrtp added breaking This is a breaking change enhancement New feature or request labels Dec 6, 2024
@jkelleyrtp jkelleyrtp merged commit 7d490dc into main Dec 7, 2024
17 checks passed
@jkelleyrtp jkelleyrtp deleted the jk/dioxus-logger-inline branch December 7, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This is a breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant