From f83c354a63a973806e62ab0d8f9004310fca05fc Mon Sep 17 00:00:00 2001 From: Sam Tay Date: Thu, 5 Sep 2024 10:57:06 -0300 Subject: [PATCH] Set different log levels per environment --- .github/workflows/production.yml | 1 + .github/workflows/staging.yml | 1 + app/src/main.rs | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 69106bc..5de8a96 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -25,6 +25,7 @@ jobs: SUPABASE_ANON_KEY: ${{ secrets.PRODUCTION_ANON_KEY }} ENV: production APP_URL: https://talkbirdyto.me + RUST_LOG: error steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index df02774..8baa1a6 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -25,6 +25,7 @@ jobs: SUPABASE_ANON_KEY: ${{ secrets.STAGING_ANON_KEY }} ENV: staging APP_URL: https://staging.talkbirdyto.me + RUST_LOG: debug steps: - uses: actions/checkout@v4 diff --git a/app/src/main.rs b/app/src/main.rs index 1d5bf63..70fb7d1 100644 --- a/app/src/main.rs +++ b/app/src/main.rs @@ -15,7 +15,10 @@ fn main() { // Init storage dioxus_sdk::set_dir!(); // Init logger - dioxus_logger::init(Level::DEBUG).expect("failed to init logger"); + let log_level = option_env!("RUST_LOG") + .and_then(|level| level.parse().ok()) + .unwrap_or(Level::INFO); + dioxus_logger::init(log_level).expect("failed to init logger"); // launch(App) // use below until --port 3000 supported on fullstack #[allow(clippy::let_unit_value)]