feat: add logging for tui

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-01 22:17:39 +02:00
parent 5327aff217
commit 1885a200c4
12 changed files with 600 additions and 11 deletions

View File

@@ -13,7 +13,13 @@ dotenv.workspace = true
axum.workspace = true
serde = { version = "1.0.197", features = ["derive"] }
sqlx = { version = "0.7.3", features = ["runtime-tokio", "tls-rustls", "postgres", "uuid", "time"] }
sqlx = { version = "0.7.3", features = [
"runtime-tokio",
"tls-rustls",
"postgres",
"uuid",
"time",
] }
uuid = { version = "1.7.0", features = ["v4"] }
tower-http = { version = "0.5.2", features = ["cors", "trace"] }
serde_json = "1.0.116"

View File

@@ -14,9 +14,18 @@ impl Querier {
root: &str,
path: impl IntoIterator<Item = impl Into<String>>,
) -> Option<GraphItem> {
let path = path.into_iter().map(|i| i.into()).collect::<Vec<String>>();
let path = path
.into_iter()
.map(|i| i.into())
.filter(|i| !i.is_empty())
.collect::<Vec<String>>();
tracing::debug!("quering: {}, len: ({}))", path.join("."), path.len());
tracing::debug!(
"quering: root:({}), path:({}), len: ({}))",
root,
path.join("."),
path.len()
);
self.engine
.get(root, &path.iter().map(|i| i.as_str()).collect::<Vec<_>>())

View File

@@ -10,6 +10,7 @@ pub struct LockFile(PathBuf);
impl Drop for LockFile {
fn drop(&mut self) {
tracing::debug!("removing lockfile");
std::fs::remove_file(&self.0).expect("to be able to delete lockfile")
}
}
@@ -76,6 +77,14 @@ impl Storage {
Ok(())
}
pub fn clear_lock_file(self) {
let mut lock_file = self.lock_file.lock().unwrap();
if lock_file.is_some() {
*lock_file = None;
}
}
fn state(&self) -> anyhow::Result<PathBuf> {
self.cache().map(|c| c.join("graph.json"))
}