diff --git a/Cargo.toml b/Cargo.toml index 8be8b9a..1b90a4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ icu = { version = "2.1.1", features = ["compiled_data"] } cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "160b086", optional = true } cosmic-mime-apps = { git = "https://github.com/pop-os/cosmic-mime-apps.git", optional = true } dirs = "6.0.0" -env_logger = "0.11" gio = { version = "0.21", optional = true } glib = { version = "0.21", optional = true } glob = "0.3" @@ -62,6 +61,8 @@ png = "0.18" jxl-oxide = { version = "0.12.5", features = ["image"] } num_cpus = "1.17.0" filetime = "0.2" +tracing = "0.1.44" +tracing-subscriber = { version = "0.3.22", features = ["env-filter"] } # Completion-based IO runtime to enable io_uring / IOCP file IO support. [dependencies.compio] diff --git a/src/lib.rs b/src/lib.rs index cc0bcc1..b4c85c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ use cosmic::{app::Settings, iced::Limits}; use std::{env, fs, path::PathBuf, process}; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use app::{App, Flags}; pub mod app; @@ -73,7 +74,22 @@ pub fn is_wayland() -> bool { /// Runs application in desktop mode #[rustfmt::skip] pub fn desktop() -> Result<(), Box> { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); + let log_format = tracing_subscriber::fmt::format() + .pretty() + .without_time() + .with_line_number(true) + .with_file(true) + .with_target(false) + .with_thread_names(true); + + let log_layer = tracing_subscriber::fmt::Layer::default() + .with_writer(std::io::stderr) + .event_format(log_format); + + tracing_subscriber::registry() + .with(tracing_subscriber::EnvFilter::from_env("RUST_LOG")) + .with(log_layer) + .init(); localize::localize(); @@ -108,7 +124,21 @@ pub fn desktop() -> Result<(), Box> { /// Runs application with these settings #[rustfmt::skip] pub fn main() -> Result<(), Box> { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); + let log_format = tracing_subscriber::fmt::format() + .pretty() + .with_line_number(true) + .with_file(true) + .with_target(false) + .with_thread_names(true); + + let log_layer = tracing_subscriber::fmt::Layer::default() + .with_writer(std::io::stderr) + .event_format(log_format); + + tracing_subscriber::registry() + .with(tracing_subscriber::EnvFilter::from_env("RUST_LOG")) + .with(log_layer) + .init(); localize::localize();