diff --git a/Cargo.lock b/Cargo.lock index 391bb96..30b5f32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -360,15 +360,6 @@ dependencies = [ "ratatui", ] -[[package]] -name = "deranged" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" -dependencies = [ - "powerfmt", -] - [[package]] name = "diff" version = "0.1.13" @@ -388,11 +379,13 @@ dependencies = [ "clap_complete", "crossbeam", "crosstermion", + "fern", "filesize", "gix-glob", "gix-path", "human_format", "itertools 0.14.0", + "jiff", "jwalk", "log", "log-panics", @@ -403,7 +396,6 @@ dependencies = [ "petgraph", "pretty_assertions", "ratatui", - "simplelog", "trash", "tui-react", "unicode-segmentation", @@ -423,6 +415,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "fern" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" +dependencies = [ + "log", +] + [[package]] name = "filesize" version = "0.2.0" @@ -658,6 +659,47 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jiff" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67e8da4c49d6d9909fe03361f9b620f58898859f5c7aded68351e85e71ecf50" +dependencies = [ + "jiff-static", + "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", + "windows-sys 0.61.2", +] + +[[package]] +name = "jiff-static" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c84ee7f197eca9a86c6fd6cb771e55eb991632f15f2bc3ca6ec838929e6e78" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68971ebff725b9e2ca27a601c5eb38a4c5d64422c4cbab0c535f248087eda5c2" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" +dependencies = [ + "jiff-tzdb", +] + [[package]] name = "js-sys" version = "0.3.82" @@ -745,12 +787,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "num-conv" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" - [[package]] name = "num-traits" version = "0.2.19" @@ -770,15 +806,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_threads" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" -dependencies = [ - "libc", -] - [[package]] name = "objc2" version = "0.6.3" @@ -896,10 +923,19 @@ dependencies = [ ] [[package]] -name = "powerfmt" -version = "0.2.0" +name = "portable-atomic" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9db96d7fa8782dd8c15ce32ffe8680bbd1e978a43bf51a34d39483540495f5" +dependencies = [ + "portable-atomic", +] [[package]] name = "pretty_assertions" @@ -1073,17 +1109,6 @@ dependencies = [ "libc", ] -[[package]] -name = "simplelog" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16257adbfaef1ee58b1363bdc0664c9b8e1e30aed86049635fb5f147d065a9c0" -dependencies = [ - "log", - "termcolor", - "time", -] - [[package]] name = "smallvec" version = "1.15.1" @@ -1145,15 +1170,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "2.0.17" @@ -1174,39 +1190,6 @@ dependencies = [ "syn", ] -[[package]] -name = "time" -version = "0.3.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" -dependencies = [ - "deranged", - "itoa", - "libc", - "num-conv", - "num_threads", - "powerfmt", - "serde_core", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" - -[[package]] -name = "time-macros" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "trash" version = "5.2.5" @@ -1366,15 +1349,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 760b6cc..db57547 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,8 @@ once_cell = "1.19" gix-glob = "0.22.1" gix-path = "0.10.10" bstr = "1.8.0" -simplelog = "0.12.1" +fern = "0.7.1" +jiff = "0.2.18" log = "0.4.20" log-panics = { version = "2", features = ["with-backtrace"] } crossbeam = "0.8" diff --git a/src/main.rs b/src/main.rs index 5966672..fb762e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,6 @@ use anyhow::Result; use clap::{CommandFactory as _, Parser}; use dua::{TraversalSorting, canonicalize_ignore_dirs}; use log::info; -use simplelog::{Config, LevelFilter, WriteLogger}; -use std::fs::OpenOptions; use std::{fs, io, io::Write, path::PathBuf, process}; #[cfg(feature = "tui-crossplatform")] @@ -32,14 +30,28 @@ fn main() -> Result<()> { if let Some(log_file) = &opt.log_file { log_panics::init(); - WriteLogger::init( - LevelFilter::Debug, - Config::default(), - OpenOptions::new() - .create(true) - .append(true) - .open(log_file)?, - )?; + + let log_output = std::fs::OpenOptions::new() + .create(true) + .append(true) + .open(log_file)?; + + fern::Dispatch::new() + .level(log::LevelFilter::Debug) + .format(|formatter_out, log_msg, log_rec| { + let when = jiff::Zoned::now(); + formatter_out.finish(format_args!( + "[{} {} {}:{}] {}", + when.strftime("%Y-%m-%d %H:%M:%S%.3f %:z"), + log_rec.level(), + log_rec.file().unwrap_or(""), + log_rec.line().unwrap_or(0), + log_msg + )) + }) + .chain(log_output) + .apply()?; + info!("dua options={opt:#?}"); }