Handsome logger
This commit is contained in:
parent
846526bbe6
commit
4fa7d51489
48
Cargo.lock
generated
48
Cargo.lock
generated
|
@ -520,7 +520,9 @@ version = "6.0.0"
|
|||
dependencies = [
|
||||
"clap",
|
||||
"czkawka_core",
|
||||
"handsome_logger",
|
||||
"image_hasher",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -539,6 +541,7 @@ dependencies = [
|
|||
"ffmpeg_cmdline_utils",
|
||||
"futures",
|
||||
"hamming",
|
||||
"handsome_logger",
|
||||
"humansize",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
|
@ -549,6 +552,7 @@ dependencies = [
|
|||
"libheif-rs",
|
||||
"libheif-sys",
|
||||
"lofty",
|
||||
"log",
|
||||
"mime_guess",
|
||||
"num_cpus",
|
||||
"once_cell",
|
||||
|
@ -580,11 +584,13 @@ dependencies = [
|
|||
"gdk4",
|
||||
"glib",
|
||||
"gtk4",
|
||||
"handsome_logger",
|
||||
"humansize",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"image",
|
||||
"image_hasher",
|
||||
"log",
|
||||
"once_cell",
|
||||
"open",
|
||||
"regex",
|
||||
|
@ -1348,6 +1354,17 @@ version = "0.1.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1"
|
||||
|
||||
[[package]]
|
||||
name = "handsome_logger"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54cd219376bdbd869ce764bf83e45407ef1a640503e2927605e8524575fda474"
|
||||
dependencies = [
|
||||
"log",
|
||||
"termcolor",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
|
@ -1951,6 +1968,15 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_threads"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc"
|
||||
version = "0.2.7"
|
||||
|
@ -3001,6 +3027,15 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.48"
|
||||
|
@ -3049,8 +3084,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"libc",
|
||||
"num_threads",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3059,6 +3098,15 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572"
|
||||
dependencies = [
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.7.1"
|
||||
|
|
|
@ -15,6 +15,9 @@ clap = { version = "4.3", features = ["derive"] }
|
|||
# For enum types
|
||||
image_hasher = "1.2"
|
||||
|
||||
log = "0.4.20"
|
||||
handsome_logger = "0.6.0"
|
||||
|
||||
[dependencies.czkawka_core]
|
||||
path = "../czkawka_core"
|
||||
version = "6.0.0"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use std::process;
|
||||
|
||||
use clap::Parser;
|
||||
use handsome_logger::{ColorChoice, Config, ConfigBuilder, LevelFilter, TerminalMode};
|
||||
|
||||
use commands::Commands;
|
||||
use czkawka_core::bad_extensions::BadExtensions;
|
||||
|
@ -30,6 +31,8 @@ mod commands;
|
|||
fn main() {
|
||||
let command = Args::parse().command;
|
||||
|
||||
handsome_logger::TermLogger::init(ConfigBuilder::default().set_level(LevelFilter::Debug).build(), TerminalMode::Mixed, ColorChoice::Always).unwrap();
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
println!("{command:?}");
|
||||
|
||||
|
|
|
@ -79,6 +79,9 @@ anyhow = { version = "1.0" }
|
|||
|
||||
state = "0.6"
|
||||
|
||||
log = "0.4.20"
|
||||
handsome_logger = "0.6.0"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
heif = ["dep:libheif-rs", "dep:libheif-sys"]
|
||||
|
|
|
@ -15,6 +15,7 @@ use std::{fs, mem};
|
|||
use crossbeam_channel::Receiver;
|
||||
use futures::channel::mpsc::UnboundedSender;
|
||||
use humansize::{format_size, BINARY};
|
||||
use log::debug;
|
||||
use rayon::prelude::*;
|
||||
use xxhash_rust::xxh3::Xxh3;
|
||||
|
||||
|
@ -505,6 +506,7 @@ impl DuplicateFinder {
|
|||
/// Read file length and puts it to different boxes(each for different lengths)
|
||||
/// If in box is only 1 result, then it is removed
|
||||
fn check_files_size(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) -> bool {
|
||||
debug!("check_file_size - start");
|
||||
let max_stage = match self.check_method {
|
||||
CheckingMethod::Size => 0,
|
||||
CheckingMethod::Hash => 2,
|
||||
|
@ -525,6 +527,7 @@ impl DuplicateFinder {
|
|||
.maximal_file_size(self.maximal_file_size)
|
||||
.build()
|
||||
.run();
|
||||
debug!("check_file_size - after finding file sizes");
|
||||
match result {
|
||||
DirTraversalResult::SuccessFiles { grouped_file_entries, warnings } => {
|
||||
self.files_with_identical_size = grouped_file_entries;
|
||||
|
@ -548,6 +551,7 @@ impl DuplicateFinder {
|
|||
self.filter_reference_folders_by_size();
|
||||
self.calculate_size_stats();
|
||||
|
||||
debug!("check_file_size - after calculating size stats/duplicates");
|
||||
true
|
||||
}
|
||||
DirTraversalResult::SuccessFolders { .. } => {
|
||||
|
@ -606,6 +610,7 @@ impl DuplicateFinder {
|
|||
let mut non_cached_files_to_check: BTreeMap<u64, Vec<FileEntry>> = Default::default();
|
||||
|
||||
if self.use_prehash_cache {
|
||||
debug!("prehash_load_cache_at_start - using prehash cache start");
|
||||
loaded_hash_map = match load_hashes_from_file(&mut self.text_messages, self.delete_outdated_cache, &self.hash_type, true) {
|
||||
Some(t) => t,
|
||||
None => Default::default(),
|
||||
|
@ -634,15 +639,19 @@ impl DuplicateFinder {
|
|||
}
|
||||
}
|
||||
}
|
||||
debug!("prehash_load_cache_at_start - using prehash cache end");
|
||||
} else {
|
||||
debug!("prehash_load_cache_at_start - not using prehash cache start");
|
||||
loaded_hash_map = Default::default();
|
||||
mem::swap(&mut self.files_with_identical_size, &mut non_cached_files_to_check);
|
||||
debug!("prehash_load_cache_at_start - not using prehash cache end");
|
||||
}
|
||||
(loaded_hash_map, records_already_cached, non_cached_files_to_check)
|
||||
}
|
||||
|
||||
fn prehash_save_cache_at_exit(&mut self, loaded_hash_map: BTreeMap<u64, Vec<FileEntry>>, pre_hash_results: &Vec<(u64, BTreeMap<String, Vec<FileEntry>>, Vec<String>)>) {
|
||||
if self.use_prehash_cache {
|
||||
debug!("prehash_save_cache_at_exit - saving prehash cache start");
|
||||
// All results = records already cached + computed results
|
||||
let mut save_cache_to_hashmap: BTreeMap<String, FileEntry> = Default::default();
|
||||
|
||||
|
@ -665,6 +674,7 @@ impl DuplicateFinder {
|
|||
}
|
||||
|
||||
save_hashes_to_file(&save_cache_to_hashmap, &mut self.text_messages, &self.hash_type, true, self.minimal_prehash_cache_file_size);
|
||||
debug!("prehash_save_cache_at_exit - saving prehash cache end");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -674,6 +684,7 @@ impl DuplicateFinder {
|
|||
progress_sender: Option<&UnboundedSender<ProgressData>>,
|
||||
pre_checked_map: &mut BTreeMap<u64, Vec<FileEntry>>,
|
||||
) -> Option<()> {
|
||||
debug!("prehashing - start");
|
||||
let check_type = self.hash_type;
|
||||
let (progress_thread_handle, progress_thread_run, atomic_counter, check_was_stopped) = prepare_thread_handler_common(
|
||||
progress_sender,
|
||||
|
@ -712,7 +723,9 @@ impl DuplicateFinder {
|
|||
.while_some()
|
||||
.collect();
|
||||
|
||||
debug!("prehashing - ended prehashing, start sending info to progress thread");
|
||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||
debug!("prehashing - ended prehashing, got info about progress thread end");
|
||||
|
||||
// Check if user aborted search(only from GUI)
|
||||
if check_was_stopped.load(Ordering::Relaxed) {
|
||||
|
@ -736,6 +749,7 @@ impl DuplicateFinder {
|
|||
|
||||
self.prehash_save_cache_at_exit(loaded_hash_map, &pre_hash_results);
|
||||
|
||||
debug!("prehashing - end");
|
||||
Some(())
|
||||
}
|
||||
|
||||
|
@ -743,11 +757,13 @@ impl DuplicateFinder {
|
|||
&mut self,
|
||||
mut pre_checked_map: BTreeMap<u64, Vec<FileEntry>>,
|
||||
) -> (BTreeMap<u64, Vec<FileEntry>>, BTreeMap<u64, Vec<FileEntry>>, BTreeMap<u64, Vec<FileEntry>>) {
|
||||
debug!("full_hashing_load_cache_at_start - start");
|
||||
let loaded_hash_map;
|
||||
let mut records_already_cached: BTreeMap<u64, Vec<FileEntry>> = Default::default();
|
||||
let mut non_cached_files_to_check: BTreeMap<u64, Vec<FileEntry>> = Default::default();
|
||||
|
||||
if self.use_cache {
|
||||
debug!("full_hashing_load_cache_at_start - using cache");
|
||||
loaded_hash_map = match load_hashes_from_file(&mut self.text_messages, self.delete_outdated_cache, &self.hash_type, false) {
|
||||
Some(t) => t,
|
||||
None => Default::default(),
|
||||
|
@ -778,9 +794,11 @@ impl DuplicateFinder {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
debug!("full_hashing_load_cache_at_start - not using cache");
|
||||
loaded_hash_map = Default::default();
|
||||
mem::swap(&mut pre_checked_map, &mut non_cached_files_to_check);
|
||||
}
|
||||
debug!("full_hashing_load_cache_at_start - end");
|
||||
(loaded_hash_map, records_already_cached, non_cached_files_to_check)
|
||||
}
|
||||
|
||||
|
@ -790,6 +808,7 @@ impl DuplicateFinder {
|
|||
full_hash_results: &mut Vec<(u64, BTreeMap<String, Vec<FileEntry>>, Vec<String>)>,
|
||||
loaded_hash_map: BTreeMap<u64, Vec<FileEntry>>,
|
||||
) {
|
||||
debug!("full_hashing_save_cache_at_exit - start");
|
||||
if !self.use_cache {
|
||||
return;
|
||||
}
|
||||
|
@ -826,6 +845,7 @@ impl DuplicateFinder {
|
|||
}
|
||||
}
|
||||
save_hashes_to_file(&all_results, &mut self.text_messages, &self.hash_type, false, self.minimal_cache_file_size);
|
||||
debug!("full_hashing_save_cache_at_exit - end");
|
||||
}
|
||||
|
||||
fn full_hashing(
|
||||
|
@ -834,6 +854,7 @@ impl DuplicateFinder {
|
|||
progress_sender: Option<&UnboundedSender<ProgressData>>,
|
||||
pre_checked_map: BTreeMap<u64, Vec<FileEntry>>,
|
||||
) -> Option<()> {
|
||||
debug!("full_hashing - start");
|
||||
let check_type = self.hash_type;
|
||||
|
||||
let (progress_thread_handle, progress_thread_run, atomic_counter, check_was_stopped) =
|
||||
|
@ -872,7 +893,9 @@ impl DuplicateFinder {
|
|||
|
||||
self.full_hashing_save_cache_at_exit(records_already_cached, &mut full_hash_results, loaded_hash_map);
|
||||
|
||||
debug!("full_hashing - starting sending info to progress thread");
|
||||
send_info_and_wait_for_ending_all_threads(&progress_thread_run, progress_thread_handle);
|
||||
debug!("full_hashing - after sending info to progress thread");
|
||||
|
||||
// Break if stop was clicked after saving to cache
|
||||
if check_was_stopped.load(Ordering::Relaxed) {
|
||||
|
@ -889,6 +912,7 @@ impl DuplicateFinder {
|
|||
}
|
||||
}
|
||||
|
||||
debug!("full_hashing - end");
|
||||
Some(())
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ i18n-embed-fl = "0.7"
|
|||
rust-embed = "8.0.0"
|
||||
once_cell = "1.18"
|
||||
|
||||
log = "0.4.20"
|
||||
handsome_logger = "0.6.0"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3.9", features = ["combaseapi", "objbase", "shobjidl_core", "windef", "winerror", "wtypesbase", "winuser"] }
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ use glib::Priority;
|
|||
use gtk4::gio::ApplicationFlags;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::Application;
|
||||
use handsome_logger::{ColorChoice, ConfigBuilder, LevelFilter, TerminalMode};
|
||||
|
||||
use connect_things::connect_about_buttons::*;
|
||||
use connect_things::connect_button_compare::*;
|
||||
|
@ -71,6 +72,7 @@ mod tests;
|
|||
fn main() {
|
||||
let application = Application::new(None::<String>, ApplicationFlags::HANDLES_OPEN | ApplicationFlags::HANDLES_COMMAND_LINE);
|
||||
application.connect_command_line(move |app, cmdline| {
|
||||
handsome_logger::TermLogger::init(ConfigBuilder::default().set_level(LevelFilter::Debug).build(), TerminalMode::Mixed, ColorChoice::Always).unwrap();
|
||||
build_ui(app, &cmdline.arguments());
|
||||
0
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue