feat: logging to log file
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(
|
||||
@@ -32,6 +33,9 @@ pub struct Cli {
|
||||
#[arg(short, long, global = true, action = clap::ArgAction::Count)]
|
||||
pub verbose: u8,
|
||||
|
||||
#[arg(long, env = "LOG_FILE", help = "Write logs to file instead of stderr")]
|
||||
pub log_file: Option<PathBuf>,
|
||||
|
||||
#[command(subcommand)]
|
||||
pub command: Option<Commands>,
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@ fn main() -> Result<()> {
|
||||
};
|
||||
env::set_var("LOG_LEVEL", log_level);
|
||||
|
||||
// Set LOG_FILE env var if provided via CLI
|
||||
if let Some(log_file) = &cli.log_file {
|
||||
env::set_var("LOG_FILE", log_file.to_string_lossy().to_string());
|
||||
}
|
||||
|
||||
let username = cli.username
|
||||
.ok_or_else(|| color_eyre::eyre::eyre!("Username required: use --username or set SOULSEEK_USERNAME env var"))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user