From b20148c73aacd711502304970b509cf34a95f614 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Thu, 27 Jul 2023 21:23:58 -0700 Subject: [PATCH] Display changes --- src/main.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2712b99..3067d0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -454,7 +454,7 @@ fn load_config(user_provided_path: Option) -> Option { let maybe_config = load_config_from_path(&path); if maybe_config.is_some() { tracing::info!( - path = %path.to_string_lossy(), + path = %path.display(), "Loaded config file" ); } @@ -466,7 +466,7 @@ fn load_config(user_provided_path: Option) -> Option { let resolved_path = resolved_path.as_deref().unwrap_or(file_path); if let Some(config) = load_config_from_path(resolved_path) { tracing::info!( - path = %resolved_path.to_string_lossy(), + path = %resolved_path.display(), "Loaded config file" ); return Some(config); @@ -477,7 +477,7 @@ fn load_config(user_provided_path: Option) -> Option { .and_then(|path| load_config_from_path(&path).map(|conf| (path, conf))) { tracing::info!( - path = %path.to_string_lossy(), + path = %path.display(), "Loaded config file" ); return Some(config); @@ -492,22 +492,18 @@ fn load_config(user_provided_path: Option) -> Option { } fn load_config_from_path>(path: P) -> Option { + let path = path.as_ref(); match std::fs::read_to_string(&path) { Ok(data) => match toml::from_str(&data) { Ok(config) => return Some(config), Err(err) => { - debug!( - "Failed to parse config file at {}: {}", - path.as_ref().to_string_lossy(), - err - ); + debug!(path = %path.display(), "Failed to parse config file: {err}"); } }, Err(err) => { debug!( - "Unable to read the config file at {}: {}", - path.as_ref().to_string_lossy(), - err + path = %path.display(), + "Unable to read the config file: {err}", ); } }