diff --git a/src/agent_data.rs b/src/agent_data.rs index e0d161c..8bd94a3 100644 --- a/src/agent_data.rs +++ b/src/agent_data.rs @@ -1,7 +1,7 @@ use gethostname::gethostname; -use log::info; use serde::{Deserialize, Serialize}; use std::path::PathBuf; +use tracing::info; #[derive(Debug, Deserialize, Serialize, Clone)] struct AgentVersion { diff --git a/src/file_info.rs b/src/file_info.rs index 7c4906c..b89e8d7 100644 --- a/src/file_info.rs +++ b/src/file_info.rs @@ -9,6 +9,7 @@ use std::{ path::{Path, PathBuf}, time::SystemTime, }; +use tracing::warn; use xxhash_rust::xxh3::xxh3_128; #[derive(Debug, Serialize, Deserialize, Clone)] @@ -129,9 +130,9 @@ pub fn create_file_info(path: &PathBuf) -> Option { }) } Err(err) => { - warn!("Could not get access to {} metadata: {}", path, err); + warn!("Could not get access to {:?} metadata: {}", path, err); None - }, + } } } @@ -157,14 +158,18 @@ mod tests { #[test] fn test_get_file_signature() { - let path = PathBuf::from(vec![r"tests", r"assets", r"test_folder", r"test-file-1"].iter().collect()); + let path: PathBuf = [r"tests", r"assets", r"test_folder", r"test-file-1"] + .iter() + .collect(); let hash = get_file_signature(&path); assert_eq!(hash, 53180848542178601830765469314885156230); } #[test] fn test_create_file_info() { - let path = PathBuf::from(vec![r"tests", r"assets", r"test_folder", r"test-file-1"].iter().collect()); + let path: PathBuf = [r"tests", r"assets", r"test_folder", r"test-file-1"] + .iter() + .collect(); if let Some(file_info) = create_file_info(&path) { assert_eq!(file_info.path, path); assert_eq!(file_info.size, 100); diff --git a/src/file_watcher.rs b/src/file_watcher.rs index 163d9a5..270907a 100644 --- a/src/file_watcher.rs +++ b/src/file_watcher.rs @@ -1,9 +1,9 @@ -use log::error; use notify::RecursiveMode::Recursive as RecursiveWatcher; use notify::Watcher; use std::path::PathBuf; use std::sync::mpsc; use std::time; +use tracing::error; pub fn watch_directories( directories: Vec, diff --git a/src/http_server.rs b/src/http_server.rs index 2b1e031..b7a842e 100644 --- a/src/http_server.rs +++ b/src/http_server.rs @@ -5,7 +5,6 @@ use crate::my_files; use crate::my_files::{ConfigurationPresent, ConnectionManagerPresent, Sealed}; use axum::{extract::Query, extract::State, routing::get, Json, Router}; use lazy_static::lazy_static; -use log::{error, info}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::net::SocketAddr; @@ -13,7 +12,7 @@ use std::path::PathBuf; use std::sync::{Arc, Mutex}; use tokio::net::TcpListener; use tower_http::trace::{self, TraceLayer}; -use tracing::Level; +use tracing::{error, info, Level}; lazy_static! { static ref AGENT_LOGGING_LEVEL: HashMap = { diff --git a/src/lib.rs b/src/lib.rs index afe11d3..8a05b24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,9 +9,9 @@ mod tidy_algo; use crate::tidy_algo::tidy_algo::TidyAlgo; use http_server::HttpServerBuilder; -use log::{error, info}; use notify::EventKind; use std::{path::PathBuf, thread}; +use tracing::{error, info}; pub async fn run() { match std::env::var("TIDY_BACKTRACE") { @@ -41,8 +41,9 @@ pub async fn run() { info!("MyFilesDB sucessfully initialized"); let mut tidy_algo = TidyAlgo::new(); + let basic_ruleset_path: PathBuf = [r"config", r"rules", r"basic.yml"].iter().collect(); info!("TidyAlgo sucessfully created"); - tidy_algo.load_rules_from_file(&my_files, PathBuf::from(vec![r"config", r"rules", r"basic.yml"].iter().collect())); + tidy_algo.load_rules_from_file(&my_files, basic_ruleset_path); info!("TidyAlgo sucessfully loaded rules from config/rules/basic.yml"); list_directories(config.file_lister_config.dir, &my_files); diff --git a/src/my_files.rs b/src/my_files.rs index cd44bff..171f9f0 100644 --- a/src/my_files.rs +++ b/src/my_files.rs @@ -3,12 +3,12 @@ use crate::file_info::{FileInfo, TidyScore}; use chrono::{DateTime, Utc}; use core::marker::PhantomData; use itertools::{Either, Itertools}; -use log::{error, info, warn}; use r2d2::{Pool, PooledConnection}; use r2d2_sqlite::SqliteConnectionManager; use rusqlite::{params, Result, ToSql}; use std::path; use std::path::PathBuf; +use tracing::{error, info, warn}; // region: --- MyFiles builder states #[derive(Default, Clone)] diff --git a/src/tidy_algo/tidy_algo.rs b/src/tidy_algo/tidy_algo.rs index 20aefe3..f78b16b 100644 --- a/src/tidy_algo/tidy_algo.rs +++ b/src/tidy_algo/tidy_algo.rs @@ -4,9 +4,9 @@ use crate::tidy_algo::tidy_rules::duplicated::duplicated; use crate::tidy_algo::tidy_rules::misnamed::misnamed; use crate::tidy_algo::tidy_rules::perished::perished; use config::{Config, ConfigError, File, Value}; -use log::debug; use std::collections::HashMap; use std::path; +use tracing::debug; /// Represents a rule that can be applied to a file #[allow(dead_code)] diff --git a/src/tidy_algo/tidy_rules/duplicated.rs b/src/tidy_algo/tidy_rules/duplicated.rs index 4e019de..7a73aaa 100644 --- a/src/tidy_algo/tidy_rules/duplicated.rs +++ b/src/tidy_algo/tidy_rules/duplicated.rs @@ -1,7 +1,6 @@ -use std::collections::HashMap; - use config::Value; -use log::error; +use std::collections::HashMap; +use tracing::error; use crate::{ file_info::{FileInfo, TidyScore}, diff --git a/src/tidy_algo/tidy_rules/misnamed.rs b/src/tidy_algo/tidy_rules/misnamed.rs index 7ff3ee7..a3d0a8f 100644 --- a/src/tidy_algo/tidy_rules/misnamed.rs +++ b/src/tidy_algo/tidy_rules/misnamed.rs @@ -1,7 +1,7 @@ use config::Value; -use log::warn; use regex::Regex; use std::collections::HashMap; +use tracing::warn; use crate::{ file_info::{FileInfo, TidyScore}, diff --git a/src/tidy_algo/tidy_rules/perished.rs b/src/tidy_algo/tidy_rules/perished.rs index c4bcd83..67671bf 100644 --- a/src/tidy_algo/tidy_rules/perished.rs +++ b/src/tidy_algo/tidy_rules/perished.rs @@ -1,7 +1,7 @@ use config::Value; use lazy_static::lazy_static; -use log::warn; use std::collections::HashMap; +use tracing::warn; use crate::{ file_info::{FileInfo, TidyScore},