added log lines

This commit is contained in:
2026-03-02 23:00:24 +01:00
parent 6bb41e7d72
commit 53e4614970
5 changed files with 60 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
use log::trace;
use serde::{Deserialize, Serialize};
use std::{
error::Error,
@@ -30,6 +31,11 @@ pub struct RootConfig {
impl RootConfig {
pub fn load_from_file(path: impl AsRef<Path>) -> Result<Self, Box<dyn Error>> {
trace!(
"Loading RootConfig from file: {}",
path.as_ref().to_string_lossy()
);
let data = read_to_string(path)?;
let config = toml::from_str(&data)?;
@@ -111,6 +117,11 @@ impl ModdedInstance {
}
pub fn load_from_file(path: impl AsRef<Path>) -> Result<Self, Box<dyn Error>> {
trace!(
"Loading ModdedInstance from file: {}",
path.as_ref().to_string_lossy()
);
let data = read_to_string(path)?;
let config = toml::from_str(&data)?;
@@ -118,6 +129,11 @@ impl ModdedInstance {
}
pub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<(), Box<dyn Error>> {
trace!(
"Saving ModdedInstance to: {}",
path.as_ref().to_string_lossy()
);
let content = toml::to_string_pretty(self)?;
let mut file = fs::File::create(path)?;
write!(file, "{}", content)?;
@@ -125,6 +141,8 @@ impl ModdedInstance {
}
pub fn add_mod(&mut self, from_mod: &ModConfig, priority: isize, files: &[ModFile]) {
trace!("Adding mod to instance");
let mut new_mod = InstalledMod::new(from_mod, priority);
let mut solver = ConflictSolver::new();
@@ -137,10 +155,12 @@ impl ModdedInstance {
}
}
trace!("Adding already present files to confict solver");
for (present_file, present_mod) in &already_installed_files {
solver.add_file_unchecked(present_file, present_mod);
}
trace!("Adding file from mod to confict solver");
// Now add the new files and check for conflicts
for file in files {
if let Some(conflict) = solver.add_file(file, &new_mod) {
@@ -150,6 +170,7 @@ impl ModdedInstance {
}
}
trace!("No conflicts where found");
// No conflicts. Add files.
for file in files {
new_mod.add_file(file);