Skip to content

Commit 910d218

Browse files
committed
allow forcing debug logging using environment variable
1 parent 3191a3a commit 910d218

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use clap::Parser;
22
use cli::Command;
33
use server::config::Config;
4+
use std::env;
45
use tracing::{debug, info};
56

67
mod cli;
@@ -17,8 +18,11 @@ async fn main() -> Result<(), error::Error> {
1718
let args = cli::Cli::parse();
1819
let config_path = args.config.clone().unwrap_or_else(Config::default_path);
1920
let (config, first_run) = server::config::setup(&config_path)?;
21+
let force_debug = args.debug
22+
|| env::var("PWMP_DEBUG")
23+
.is_ok_and(|value| ["OK", "1", "YES", "true"].contains(&value.to_lowercase().as_str()));
2024

21-
if let Err(why) = logging::setup(args.debug, &config) {
25+
if let Err(why) = logging::setup(force_debug, &config) {
2226
eprintln!("Failed to set up logging: {why}");
2327
return Err(why);
2428
}

0 commit comments

Comments
 (0)