summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzjp <jiping_zhou@foxmail.com>2023-05-12 23:32:00 +0800
committerDenis Isidoro <denis.isidoro@uber.com>2023-12-10 06:25:29 -0300
commit4d077ba61283cddcf72fd868d8d8c5931313052f (patch)
tree95adda211403b70a27b76b39497caff51192cee7
parente2c4b2b67eac9ff067b072f630468d5f925e2849 (diff)
mv navi.log under config dir; debug folders on Windows
2023-05-12T15:51:54.280707Z DEBUG navi::filesystem: read cheat files in `"C"`: [] 2023-05-12T15:51:54.281083Z DEBUG navi::filesystem: read cheat files in `"\\Users\\Administrator\\AppData\\Roaming\\navi\\cheats"`: []
-rw-r--r--src/bin/main.rs10
-rw-r--r--src/filesystem.rs6
-rw-r--r--src/lib.rs2
3 files changed, 12 insertions, 6 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index a9b90b0..01f9ffb 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -1,6 +1,6 @@
extern crate navi;
-use dns_common::prelude::{debug, error, tracing, tracing_subscriber};
+use dns_common::prelude::*;
use thiserror::Error;
#[derive(Error, Debug)]
@@ -33,14 +33,18 @@ fn main() -> Result<(), anyhow::Error> {
}
fn init_logger() -> anyhow::Result<()> {
+ const FILE_NAME: &str = "navi.log";
+ let mut file = navi::default_config_pathbuf()?;
+ file.set_file_name(FILE_NAME);
+
tracing::subscriber::set_global_default(
tracing_subscriber::fmt()
.with_ansi(false)
- // TODO: config_path/navi.log
- .with_writer(std::fs::File::create("navi.log")?)
+ .with_writer(std::fs::File::create(file)?)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.finish(),
)?;
debug!("tracing initialized");
+
Ok(())
}
diff --git a/src/filesystem.rs b/src/filesystem.rs
index fe4df97..bebe1d8 100644
--- a/src/filesystem.rs
+++ b/src/filesystem.rs
@@ -166,7 +166,9 @@ impl fetcher::Fetcher for Fetcher {
None => folder.to_string(),
};
let folder_pathbuf = PathBuf::from(interpolated_folder);
- for file in all_cheat_files(&folder_pathbuf) {
+ let cheat_files = all_cheat_files(&folder_pathbuf);
+ debug!("read cheat files in `{folder_pathbuf:?}`: {cheat_files:#?}");
+ for file in cheat_files {
self.files.borrow_mut().push(file.clone());
let index = self.files.borrow().len() - 1;
let read_file_result = {
@@ -181,7 +183,7 @@ impl fetcher::Fetcher for Fetcher {
}
}
- debug!("filesystem::Fetcher = {self:#?}");
+ debug!("{self:#?}");
Ok(found_something)
}
diff --git a/src/lib.rs b/src/lib.rs
index f4a434f..bc2bdf6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,4 +14,4 @@ mod prelude;
mod structures;
mod welcome;
-pub use commands::handle;
+pub use {commands::handle, filesystem::default_config_pathbuf};