summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorzjp <jiping_zhou@foxmail.com>2023-05-12 23:32:00 +0800
committerzjp <jiping_zhou@foxmail.com>2023-05-13 00:21:31 +0800
commit2755d51b38a9badf28fa2b041b533aa7f0e8998d (patch)
treeee7fedf3fb7668f755bad56f32a498fd00437252 /src
parent818d5cdc0e3de89a464107378649f92a0c215ed1 (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"`: []
Diffstat (limited to 'src')
-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};