feat(logging): add --log arg to enable logs

and/or to pass a custom log directory.
This commit is contained in:
jk
2025-02-06 20:33:52 +01:00
parent 843c4d019d
commit e094d7d81b
5 changed files with 58 additions and 11 deletions

View File

@@ -5,10 +5,11 @@ use crate::{
#[cfg(feature = "sound")]
use crate::{sound, sound::SoundError};
use clap::Parser;
#[cfg(feature = "sound")]
use std::path::PathBuf;
use std::time::Duration;
pub const LOG_DIRECTORY_DEFAULT_MISSING_VALUE: &str = " "; // empty string
#[derive(Parser)]
#[command(version)]
pub struct Args {
@@ -66,6 +67,19 @@ pub struct Args {
value_parser = sound_file_parser,
)]
pub sound: Option<PathBuf>,
#[arg(
long,
// allows both --log=path and --log path syntax
num_args = 0..=1,
// Note: If no value is passed, use a " " by default,
// this value will be checked later in `main`
// to use another (default) log directory instead
default_missing_value=LOG_DIRECTORY_DEFAULT_MISSING_VALUE,
help = "Directory to store log file. If not set, standard application log directory is used (check README for details).",
value_hint = clap::ValueHint::DirPath,
)]
pub log: Option<PathBuf>,
}
#[cfg(feature = "sound")]