Skip to content

Commit

Permalink
Fix overridden log dir
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jan 4, 2025
1 parent ea0483a commit 3c79a79
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,25 @@ unsafe fn detach_console() {

fn main() {
let mut failed = false;
let args = cli::parse();

let mut logger = prepare_logging();
if let Some(config_dir) = args.as_ref().ok().and_then(|args| args.config.as_ref()) {
*CONFIG_DIR.lock().unwrap() = Some(config_dir.clone());
}

let logger = prepare_logging();
#[allow(clippy::useless_asref)]
prepare_panic_hook(logger.as_ref().map(|x| x.clone()).ok());
let mut flush_logger = || {
if let Ok(logger) = &mut logger {
let flush_logger = || {
if let Ok(logger) = &logger {
logger.flush();
}
};

log::debug!("Version: {}", *VERSION);
log::debug!("Invocation: {:?}", std::env::args());

let args = match cli::parse() {
let args = match args {
Ok(x) => x,
Err(e) => {
match e.kind() {
Expand All @@ -180,9 +185,6 @@ fn main() {
}
};

if let Some(config_dir) = args.config.as_deref() {
*CONFIG_DIR.lock().unwrap() = Some(config_dir.to_path_buf());
}
match args.sub {
None => {
#[cfg(target_os = "windows")]
Expand Down

0 comments on commit 3c79a79

Please sign in to comment.