From 76f621a8454389ffbe1a6fe7fada0deeebf2f757 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Wed, 17 May 2023 16:47:00 +0200 Subject: feat: Better logging regarding mod installation (#363) * fix: Make log comment more specific * feat: Log attempting to create temp dir * feat: Log mod to install and GameInstall struct * refactor: Replace `dbg` with proper logging * refactor: Replace `dbg` with proper logging * feat: Warning log mod install error * style: Fix formatting * feat: Log libthermite error and modstring when mod install fails --- src-tauri/src/main.rs | 10 ++++++++-- src-tauri/src/mod_management/mod.rs | 10 +++++++--- src-tauri/src/northstar/install.rs | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5675a0df..b27233b7 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -308,7 +308,7 @@ async fn install_northstar_caller( northstar_package_name: Option, version_number: Option, ) -> Result { - log::info!("Running"); + log::info!("Running Northstar install"); // Get Northstar package name (`Northstar` vs `NorthstarReleaseCandidate`) let northstar_package_name = northstar_package_name @@ -356,7 +356,13 @@ async fn install_mod_caller( game_install: GameInstall, thunderstore_mod_string: String, ) -> Result<(), String> { - fc_download_mod_and_install(&game_install, &thunderstore_mod_string).await?; + match fc_download_mod_and_install(&game_install, &thunderstore_mod_string).await { + Ok(()) => (), + Err(err) => { + log::warn!("{err}"); + return Err(err); + } + }; match clean_up_download_folder(&game_install, false) { Ok(()) => Ok(()), Err(err) => { diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 455aa424..43464c8f 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -340,7 +340,7 @@ async fn get_ns_mod_download_url(thunderstore_mod_string: &str) -> Result Result, anyhow::Error> { - dbg!(thunderstore_mod_string); + log::info!("Attempting to get dependencies for: {thunderstore_mod_string}"); // TODO: This will crash the thread if not internet connection exist. `match` should be used instead let index = thermite::api::get_package_index().unwrap().to_vec(); @@ -369,6 +369,7 @@ pub async fn fc_download_mod_and_install( game_install: &GameInstall, thunderstore_mod_string: &str, ) -> Result<(), String> { + log::info!("Attempting to install \"{thunderstore_mod_string}\" to {game_install:?}"); // Get mods and download directories let download_directory = format!( "{}/___flightcore-temp-download-dir/", @@ -385,7 +386,7 @@ pub async fn fc_download_mod_and_install( Ok(deps) => deps, Err(err) => return Err(err.to_string()), }; - dbg!(deps.clone()); + log::info!("Mod dependencies: {deps:?}"); // Recursively install dependencies for dep in deps { @@ -439,7 +440,10 @@ pub async fn fc_download_mod_and_install( std::path::Path::new(&mods_directory), ) { Ok(()) => (), - Err(err) => return Err(err.to_string()), + Err(err) => { + log::warn!("libthermite couldn't install mod {thunderstore_mod_string} due to {err:?}",); + return Err(err.to_string()); + } }; Ok(()) diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index 235c35ff..344c0ccf 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -38,6 +38,10 @@ async fn do_install( let filename = format!("northstar-{}.zip", nmod.version); let download_directory = format!("{}/___flightcore-temp-download-dir/", game_path.display()); + log::info!( + "Attempting to create temporary directory {}", + download_directory + ); std::fs::create_dir_all(download_directory.clone())?; let download_path = format!("{}/{}", download_directory, filename); -- cgit v1.2.3