diff --git a/server/main-api/README.md b/server/main-api/README.md index a8282ce81..953455bde 100644 --- a/server/main-api/README.md +++ b/server/main-api/README.md @@ -55,6 +55,7 @@ The server should now be available on `localhost:8080` if you have configured th |-----------------------------------|----------------------------------|-----------------------------------------|--------------------------------------------------------------------------------------------------------| | `POSTGRES_{USER,PASSWORD,URL,DB}` | [`all`](./main.rs) | required | Used to connect to the db | | `GIT_COMMIT_SHA` | [`main`](./main.rs) | optional | Shown in the status endpint (also set at build time in docker) | +| `LOG_LEVEL` | [`main`](./main.rs) | optional | Shown in the status endpint (also set at build time in docker) | | `GITHUB_TOKEN` | [`feedback`](./feeedback/mod.rs) | | A GitHub token with `write` access to `repo`.
This is used to create issues/PRs on the repository. | | `JWT_KEY` | [`feedback`](./feeedback/mod.rs) | | A key used to sign JWTs.
This is used to authenticate that feedback tokens were given out by us. | | `MIELI_{URL,MASTER_KEY}` | [`search`](./search/mod.rs) | | Allows searching via meiliserch | diff --git a/server/main-api/src/main.rs b/server/main-api/src/main.rs index c42bfddd5..cb6b77056 100644 --- a/server/main-api/src/main.rs +++ b/server/main-api/src/main.rs @@ -57,17 +57,22 @@ fn connection_string() -> String { fn setup_logging() { #[cfg(debug_assertions)] { + let log_level = std::env::var("LOG_LEVEL").unwrap_or_else(|_|"debug".to_string()); + let filter = format!("{log_level},hyper=info,rustls=info,h2=info,sqlx=info,hickory_resolver=info,hickory_proto=info"); let env = env_logger::Env::default() - .default_filter_or("debug,hyper=info,rustls=info,h2=info,sqlx=info,hickory_resolver=info,hickory_proto=info"); + .default_filter_or(&filter); env_logger::Builder::from_env(env).init(); } #[cfg(not(debug_assertions))] - structured_logger::Builder::with_level("info") - .with_target_writer( - "*", - structured_logger::async_json::new_writer(tokio::io::stdout()), - ) - .init(); + { + let log_level = std::env::var("LOG_LEVEL").unwrap_or_else(|_|"info".to_string()); + structured_logger::Builder::with_level(&log_level) + .with_target_writer( + "*", + structured_logger::async_json::new_writer(tokio::io::stdout()), + ) + .init(); + } } #[tokio::main]