diff --git a/Cargo.lock b/Cargo.lock index 2eb0338b..286c19d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,6 @@ dependencies = [ "sysctl", "sysinfo", "tempfile", - "time", "timeless", "toml_edit", "unicode-ellipsis", diff --git a/Cargo.toml b/Cargo.toml index 8384b752..a707c495 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ path = "src/bin/main.rs" doc = false [features] -# Used for general builds. +# Used for general release builds. battery = ["dep:starship-battery"] nvidia = ["gpu", "dep:nvml-wrapper"] gpu = [] @@ -62,18 +62,13 @@ zfs = [] deploy = ["battery", "nvidia", "zfs"] default = ["deploy"] -# Should not be included in builds. -logging = ["fern", "log", "time"] +# These features should not be included in release builds. +logging = ["fern", "log"] generate_schema = ["schemars", "strum"] [dependencies] anyhow = "1.0.101" -clap = { version = "4.6.4", features = [ - "default", - "cargo", - "wrap_help", - "derive", -] } +clap = { version = "4.6.4", features = ["default", "cargo", "wrap_help", "derive"] } concat-string = "1.0.1" crossterm = "0.29.0" ctrlc = { version = "3.5.2", features = ["termination"] } @@ -82,9 +77,7 @@ humantime = "2.3.0" indexmap = "2.14.0" indoc = "2.0.7" itertools = "0.15.0" -nvml-wrapper = { version = "0.12.1", optional = true, features = [ - "legacy-functions", -] } +nvml-wrapper = { version = "0.12.1", optional = true, features = ["legacy-functions"] } ratatui = { version = "0.30.2", default-features = false, features = [ "unstable-rendered-line-info", "layout-cache", @@ -102,14 +95,9 @@ unicode-ellipsis = "0.6.0" unicode-segmentation = "1.13.3" unicode-width = "0.2.2" -# Used for logging. Mostly a debugging tool. +# Used for logging. Mostly for dev-level debugging. fern = { version = "0.7.1", optional = true } log = { version = "0.4.29", optional = true } -time = { version = "0.3.47", features = [ - "local-offset", - "formatting", - "macros", -], optional = true } # These are just used for JSON schema generation. schemars = { version = "1.2.1", optional = true } @@ -150,12 +138,7 @@ tempfile = { version = "3.23.0", default-features = false } portable-pty = "0.9.0" [build-dependencies] -clap = { version = "4.6.4", features = [ - "default", - "cargo", - "wrap_help", - "derive", -] } +clap = { version = "4.6.4", features = ["default", "cargo", "wrap_help", "derive"] } clap_complete = "4.6.7" clap_complete_nushell = "4.6.1" clap_complete_fig = "4.5.2" diff --git a/src/app/data/time_series.rs b/src/app/data/time_series.rs index 22a8c4a5..4a3828cf 100644 --- a/src/app/data/time_series.rs +++ b/src/app/data/time_series.rs @@ -297,7 +297,8 @@ impl TimeSeriesData { partition_point - 1 } else { // If the partition point was 0, then it means all values are too new to be - // pruned. crate::info!("Skipping prune."); + // pruned. + // crate::info!("Skipping prune."); return; } }; diff --git a/src/lib.rs b/src/lib.rs index 5b3bfc71..55d16f13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -293,7 +293,6 @@ fn create_collection_thread( #[inline] pub fn start_bottom(enable_error_hook: &mut bool) -> anyhow::Result<()> { // let _profiler = dhat::Profiler::new_heap(); - let args = args::get_args(); #[cfg(feature = "logging")] diff --git a/src/utils/logging.rs b/src/utils/logging.rs index d5088581..0c777745 100644 --- a/src/utils/logging.rs +++ b/src/utils/logging.rs @@ -1,33 +1,12 @@ -#[cfg(feature = "logging")] -use std::sync::OnceLock; - -#[cfg(feature = "logging")] -pub static OFFSET: OnceLock = OnceLock::new(); - #[cfg(feature = "logging")] pub fn init_logger( min_level: log::LevelFilter, debug_file_name: Option<&std::ffi::OsStr>, ) -> anyhow::Result<()> { let dispatch = fern::Dispatch::new() .format(|out, message, record| { - let offset = OFFSET.get_or_init(|| { - time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC) - }); - - let offset_time = { - let utc = time::OffsetDateTime::now_utc(); - utc.checked_to_offset(*offset).unwrap_or(utc) - }; - out.finish(format_args!( - "{}[{}][{}] {}", - offset_time - .format(&time::macros::format_description!( - // The weird "[[[" is because we need to escape a bracket ("[[") to show - // one "[". See https://time-rs.github.io/book/api/format-description.html - "[[[year]-[month]-[day]][[[hour]:[minute]:[second][subsecond digits:9]]" - )) - .expect("log formatting shouldn't fail"), + "[{}][{}][{}] {}", + humantime::format_rfc3339_nanos(std::time::SystemTime::now()), record.target(), record.level(), message @@ -125,12 +104,13 @@ macro_rules! log_every_n_secs { ($level:expr, $n:expr, $($x:tt)*) => { #[cfg(feature = "logging")] { - static LAST_LOG: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); - let since_last_log = LAST_LOG.load(std::sync::atomic::Ordering::Relaxed); + use std::sync::atomic::{AtomicU64, Ordering}; + static LAST_LOG: AtomicU64 = AtomicU64::new(0); + let since_last_log = LAST_LOG.load(Ordering::Relaxed); let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).expect("should be valid").as_secs(); if now - since_last_log > $n { - LAST_LOG.store(now, std::sync::atomic::Ordering::Relaxed); + LAST_LOG.store(now, Ordering::Relaxed); log::log!($level, $($x)*); } }