1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-20 11:47:46 +00:00

Add logging crate

This commit is contained in:
Joshua Goins 2023-04-06 14:51:40 -04:00
parent f84bd8295d
commit 540341cf57
2 changed files with 9 additions and 0 deletions

View file

@ -51,6 +51,8 @@ patch_testing = ["game_install"]
# amazing binary parsing/writing library # amazing binary parsing/writing library
binrw = "0.11.1" binrw = "0.11.1"
tracing = "0.1.37"
# used for zlib compression in sqpack files # used for zlib compression in sqpack files
libz-sys = { version = "1.1", default-features = false } libz-sys = { version = "1.1", default-features = false }

View file

@ -10,6 +10,7 @@ use crate::sqpack::calculate_hash;
use std::fs; use std::fs;
use std::fs::DirEntry; use std::fs::DirEntry;
use std::path::PathBuf; use std::path::PathBuf;
use tracing::{debug, error, info, span, warn, Level};
/// Framework for operating on game data. /// Framework for operating on game data.
pub struct GameData { pub struct GameData {
@ -59,6 +60,8 @@ impl GameData {
/// GameData::from_existing("$FFXIV/game"); /// GameData::from_existing("$FFXIV/game");
/// ``` /// ```
pub fn from_existing(directory: &str) -> Option<GameData> { pub fn from_existing(directory: &str) -> Option<GameData> {
debug!(directory, "Loading game directory");
match is_valid(directory) { match is_valid(directory) {
true => Some(Self { true => Some(Self {
game_directory: String::from(directory), game_directory: String::from(directory),
@ -94,6 +97,8 @@ impl GameData {
.collect(); .collect();
for repository_path in repository_paths { for repository_path in repository_paths {
debug!(repository_path=repository_path.path().to_str(), "Found repository");
self.repositories self.repositories
.push(Repository::from_existing(repository_path.path().to_str().unwrap()).unwrap()); .push(Repository::from_existing(repository_path.path().to_str().unwrap()).unwrap());
} }
@ -169,6 +174,8 @@ impl GameData {
/// file.write(data.as_slice()).unwrap(); /// file.write(data.as_slice()).unwrap();
/// ``` /// ```
pub fn extract(&self, path: &str) -> Option<MemoryBuffer> { pub fn extract(&self, path: &str) -> Option<MemoryBuffer> {
debug!(file=path, "Extracting file");
let hash = calculate_hash(path); let hash = calculate_hash(path);
let index_file = self.get_index_file(path)?; let index_file = self.get_index_file(path)?;