diff --git a/src/main.rs b/src/main.rs index 95098465..f0326b85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ use path::manager::Manager; use std::net::SocketAddr; use std::str::FromStr; use std::sync::Arc; +use std::env; use tower_http::validate_request::ValidateRequestHeaderLayer; use webrtc::peer_connection::sdp::session_description::RTCSessionDescription; @@ -27,9 +28,19 @@ mod path; #[tokio::main] async fn main() { + let log_level = env::var("LOG_LEVEL").unwrap_or_else(|_| "info".to_string()); + let level_filter = match log_level.as_str() { + "off" => log::LevelFilter::Off, + "error" => log::LevelFilter::Error, + "warn" => log::LevelFilter::Warn, + "info" => log::LevelFilter::Info, + "debug" => log::LevelFilter::Debug, + "trace" => log::LevelFilter::Trace, + _ => log::LevelFilter::Info, + }; env_logger::builder() - .filter_level(log::LevelFilter::Debug) - .filter_module("webrtc", log::LevelFilter::Trace) + .filter_level(level_filter) + .filter_module("webrtc", log::LevelFilter::Error) .write_style(env_logger::WriteStyle::Auto) .target(env_logger::Target::Stdout) .init();