diff --git a/Cargo.lock b/Cargo.lock index 3d82ea8..7725314 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -938,6 +938,33 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "color-eyre" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -1176,6 +1203,7 @@ dependencies = [ "chrono", "chrono-tz", "clap_lex", + "color-eyre", "cosmic-applets-config", "cosmic-bg-config", "cosmic-client-toolkit", @@ -1189,7 +1217,6 @@ dependencies = [ "cosmic-settings-daemon-config", "cosmic-settings-subscriptions", "dirs 6.0.0", - "env_logger", "freedesktop_entry_parser", "futures-util", "greetd_ipc", @@ -1198,7 +1225,6 @@ dependencies = [ "icu", "kdl", "libcosmic", - "log", "logind-zbus", "nix 0.29.0", "pam-client", @@ -1208,6 +1234,9 @@ dependencies = [ "shlex", "timedate-zbus", "tokio", + "tracing", + "tracing-journald", + "tracing-subscriber", "upower_dbus", "vergen", "wayland-client", @@ -1221,29 +1250,31 @@ name = "cosmic-greeter-config" version = "0.1.0" dependencies = [ "cosmic-config", - "log", "serde", + "tracing", ] [[package]] name = "cosmic-greeter-daemon" version = "0.1.0" dependencies = [ + "color-eyre", "cosmic-applets-config", "cosmic-bg-config", "cosmic-comp-config", "cosmic-config", "cosmic-randr-shell", "cosmic-theme", - "env_logger", "kdl", "libc", - "log", "nix 0.29.0", "pwd", "ron 0.10.1", "serde", "tokio", + "tracing", + "tracing-journald", + "tracing-subscriber", "xdg 3.0.0", "zbus 5.10.0", ] @@ -1796,19 +1827,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -1888,6 +1906,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fast-srgb8" version = "1.0.0" @@ -2529,12 +2557,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" -[[package]] -name = "humantime" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" - [[package]] name = "i18n-config" version = "0.4.8" @@ -3390,6 +3412,12 @@ dependencies = [ "arrayvec", ] +[[package]] +name = "indenter" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" + [[package]] name = "indexmap" version = "1.9.3" @@ -3510,17 +3538,6 @@ dependencies = [ "libc", ] -[[package]] -name = "is-terminal" -version = "0.4.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" -dependencies = [ - "hermit-abi 0.5.2", - "libc", - "windows-sys 0.59.0", -] - [[package]] name = "itertools" version = "0.12.1" @@ -3932,6 +3949,15 @@ dependencies = [ "libc", ] +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata 0.4.10", +] + [[package]] name = "memchr" version = "2.7.5" @@ -4190,6 +4216,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" +[[package]] +name = "nu-ansi-term" +version = "0.50.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "num" version = "0.4.3" @@ -4670,6 +4705,12 @@ dependencies = [ "ttf-parser 0.25.1", ] +[[package]] +name = "owo-colors" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" + [[package]] name = "palette" version = "0.7.6" @@ -5721,6 +5762,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -6076,6 +6126,15 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + [[package]] name = "time" version = "0.3.41" @@ -6301,6 +6360,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-journald" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0b4143302cf1022dac868d521e36e8b27691f72c84b3311750d5188ebba657" +dependencies = [ + "libc", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata 0.4.10", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -6514,6 +6624,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + [[package]] name = "vergen" version = "8.3.2" diff --git a/Cargo.toml b/Cargo.toml index ec73374..179e4d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ cosmic-config = { workspace = true, features = ["calloop", "macro"] } cosmic-greeter-config.workspace = true cosmic-greeter-daemon = { path = "daemon" } dirs = "6" -env_logger.workspace = true freedesktop_entry_parser = "1.3.0" libcosmic = { workspace = true, features = [ "autosize", @@ -34,7 +33,9 @@ libcosmic = { workspace = true, features = [ "tokio", "dbus-config", ] } -log.workspace = true +tracing.workspace = true +tracing-journald = { workspace = true, optional = true } +tracing-subscriber = { workspace = true, features = ["env-filter"] } pam-client = "0.5.0" pwd.workspace = true ron.workspace = true @@ -79,15 +80,16 @@ futures-util = "0.3.30" timedate-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" } cosmic-randr-shell = { workspace = true } kdl.workspace = true - +color-eyre.workspace = true [dependencies.greetd_ipc] version = "0.10.3" features = ["tokio-codec"] [features] -default = ["logind", "networkmanager", "upower"] -logind = ["logind-zbus", "zbus"] +default = ["logind", "networkmanager", "upower", "systemd"] +logind = ["logind-zbus", "zbus", "systemd"] +systemd = ["tracing-journald"] networkmanager = ["cosmic-dbus-networkmanager", "zbus"] upower = ["upower_dbus", "zbus"] zbus = ["dep:zbus", "nix"] @@ -110,8 +112,10 @@ resolver = "2" rust-version = "1.85.0" [workspace.dependencies] -env_logger = "0.10.2" -log = "0.4.22" +tracing = "0.1" +tracing-journald = { version = "0.3" } +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +color-eyre = "0.6.5" # Fix zbus compilation by manually adding nix with user feature nix = { version = "0.29", features = ["user"] } diff --git a/cosmic-greeter-config/Cargo.toml b/cosmic-greeter-config/Cargo.toml index d85a445..839f657 100644 --- a/cosmic-greeter-config/Cargo.toml +++ b/cosmic-greeter-config/Cargo.toml @@ -8,5 +8,5 @@ license = "GPL-3.0-only" [dependencies] cosmic-config.workspace = true -log.workspace = true +tracing.workspace = true serde.workspace = true diff --git a/cosmic-greeter-config/src/lib.rs b/cosmic-greeter-config/src/lib.rs index bd4407d..27fc12e 100644 --- a/cosmic-greeter-config/src/lib.rs +++ b/cosmic-greeter-config/src/lib.rs @@ -35,14 +35,14 @@ where let config = C::get_entry(&handler) .inspect_err(|(errors, _)| { for err in errors.iter().filter(|err| err.is_err()) { - log::error!("{err}") + tracing::error!("{err}") } }) .unwrap_or_else(|(_, config)| config); (config, Some(handler)) } Err(e) => { - log::error!("Failed to get settings for `{APP_ID}` (v {CONFIG_VERSION}): {e:?}"); + tracing::error!("Failed to get settings for `{APP_ID}` (v {CONFIG_VERSION}): {e:?}"); (C::default(), None) } } diff --git a/cosmic-greeter-start.sh b/cosmic-greeter-start.sh index 2e0cbf2..b13c1f2 100644 --- a/cosmic-greeter-start.sh +++ b/cosmic-greeter-start.sh @@ -1,3 +1,3 @@ #!/bin/sh -rm -rf /run/cosmic-greeter/cosmic/com.system76.CosmicSettingsDaemon/v1/* -exec cosmic-comp systemd-cat -t cosmic-greeter cosmic-greeter +rm -rf /run/cosmic-greeter/cosmic/com.system76.CosmicSettingsDaemon/v1/* > /dev/null 2>&1 +exec cosmic-comp cosmic-greeter > /dev/null 2>&1 \ No newline at end of file diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 1e1a7da..bdcdf97 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -6,14 +6,16 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +tracing-subscriber = { workspace = true, features = ["env-filter"] } +libc = "0.2" cosmic-applets-config.workspace = true cosmic-bg-config.workspace = true cosmic-comp-config.workspace = true cosmic-config.workspace = true cosmic-theme.workspace = true -env_logger.workspace = true -libc = "0.2" -log.workspace = true +tracing.workspace = true +tracing-journald = { workspace = true, optional = true } +color-eyre.workspace = true nix.workspace = true pwd.workspace = true ron.workspace = true @@ -25,3 +27,7 @@ kdl.workspace = true #TODO: reduce features tokio = { workspace = true, features = ["full"] } xdg = "3.0.0" + +[features] +default = ["systemd"] +systemd = ["tracing-journald"] diff --git a/daemon/src/lib.rs b/daemon/src/lib.rs index 74546c5..feee714 100644 --- a/daemon/src/lib.rs +++ b/daemon/src/lib.rs @@ -50,7 +50,7 @@ impl UserData { self.bg_path_data.insert(path.clone(), bytes); } Err(err) => { - log::error!("failed to read wallpaper {:?}: {:?}", path, err); + tracing::error!("failed to read wallpaper {:?}: {:?}", path, err); } } } @@ -80,7 +80,7 @@ impl UserData { self.icon_opt = Some(icon_data); } Err(err) => { - log::error!("failed to read icon {:?}: {:?}", icon_path, err); + tracing::error!("failed to read icon {:?}: {:?}", icon_path, err); } } } @@ -92,12 +92,12 @@ impl UserData { is_dark = theme_mode.is_dark; } Err((errs, theme_mode)) => { - log::error!("failed to load cosmic-theme config: {:?}", errs); + tracing::error!("failed to load cosmic-theme config: {:?}", errs); is_dark = theme_mode.is_dark; } }, Err(err) => { - log::error!("failed to create cosmic-theme mode helper: {:?}", err); + tracing::error!("failed to create cosmic-theme mode helper: {:?}", err); } } @@ -111,12 +111,12 @@ impl UserData { self.theme_opt = Some(theme); } Err((errs, theme)) => { - log::error!("failed to load cosmic-theme config: {:?}", errs); + tracing::error!("failed to load cosmic-theme config: {:?}", errs); self.theme_opt = Some(theme); } }, Err(err) => { - log::error!("failed to create cosmic-theme config helper: {:?}", err); + tracing::error!("failed to create cosmic-theme config helper: {:?}", err); } } @@ -130,12 +130,12 @@ impl UserData { self.theme_builder_opt = Some(theme); } Err((errs, theme)) => { - log::error!("failed to load cosmic-theme builder config: {:?}", errs); + tracing::error!("failed to load cosmic-theme builder config: {:?}", errs); self.theme_builder_opt = Some(theme); } }, Err(err) => { - log::error!( + tracing::error!( "failed to create cosmic-theme builder config helper: {:?}", err ); @@ -149,12 +149,12 @@ impl UserData { self.bg_state = state; } Err((errs, state)) => { - log::error!("failed to load cosmic-bg state: {:?}", errs); + tracing::error!("failed to load cosmic-bg state: {:?}", errs); self.bg_state = state; } }, Err(err) => { - log::error!("failed to create cosmic-bg state helper: {:?}", err); + tracing::error!("failed to create cosmic-bg state helper: {:?}", err); } } self.load_wallpapers_as_user(); @@ -167,14 +167,14 @@ impl UserData { self.accessibility_zoom = config.accessibility_zoom; } Err((errs, config)) => { - log::error!("errors loading cosmic-comp config: {:?}", errs); + tracing::error!("errors loading cosmic-comp config: {:?}", errs); self.xkb_config_opt = Some(config.xkb_config); self.accessibility_zoom = config.accessibility_zoom; } }; } Err(err) => { - log::error!("failed to create cosmic-comp config handler: {}", err); + tracing::error!("failed to create cosmic-comp config handler: {}", err); } }; @@ -198,12 +198,12 @@ impl UserData { self.time_applet_config = config; } Err((errs, config)) => { - log::error!("failed to load time applet config: {:?}", errs); + tracing::error!("failed to load time applet config: {:?}", errs); self.time_applet_config = config; } }, Err(err) => { - log::error!( + tracing::error!( "failed to create CosmicAppletTime config handler: {:?}", err ); diff --git a/daemon/src/main.rs b/daemon/src/main.rs index c0f98fc..c8a52be 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -1,5 +1,10 @@ +use color_eyre::eyre::Context; +use color_eyre::eyre::WrapErr; use cosmic_greeter_daemon::UserData; use std::{env, error::Error, future::pending, io, path::Path}; +use tracing::metadata::LevelFilter; +use tracing::{error, warn}; +use tracing_subscriber::{fmt, prelude::*, EnvFilter}; use zbus::{connection::Builder, DBusError}; //IMPORTANT: this function is critical to the security of this proxy. It must ensure that the @@ -99,7 +104,35 @@ impl GreeterProxy { #[tokio::main] async fn main() -> Result<(), Box> { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); + color_eyre::install().wrap_err("failed to install color_eyre error handler")?; + + let trace = tracing_subscriber::registry(); + let env_filter = EnvFilter::builder() + .with_default_directive(LevelFilter::WARN.into()) + .from_env_lossy(); + + #[cfg(feature = "systemd")] + if let Ok(journald) = tracing_journald::layer() { + trace + .with(journald) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; + } else { + trace + .with(fmt::layer()) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; + warn!("failed to connect to journald") + } + + #[cfg(not(feature = "systemd"))] + trace + .with(fmt::layer()) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; let _conn = Builder::system()? .name("com.system76.CosmicGreeter")? diff --git a/src/common.rs b/src/common.rs index 2afaf58..d6937ff 100644 --- a/src/common.rs +++ b/src/common.rs @@ -80,7 +80,7 @@ impl + Send + 'static> Common { ) { Ok(config_handler) => Some(config_handler), Err(err) => { - log::error!("failed to create cosmic-comp config handler: {}", err); + tracing::error!("failed to create cosmic-comp config handler: {}", err); None } }; @@ -88,7 +88,7 @@ impl + Send + 'static> Common { let layouts_opt = match xkb_data::all_keyboard_layouts() { Ok(ok) => Some(Arc::new(ok)), Err(err) => { - log::warn!("failed to load keyboard layouts: {}", err); + tracing::warn!("failed to load keyboard layouts: {}", err); None } }; @@ -141,8 +141,8 @@ impl + Send + 'static> Common { } if let Some(comp_config_handler) = &self.comp_config_handler { match comp_config_handler.set("xkb_config", xkb_config) { - Ok(()) => log::info!("updated cosmic-comp xkb_config"), - Err(err) => log::error!("failed to update cosmic-comp xkb_config: {}", err), + Ok(()) => tracing::info!("updated cosmic-comp xkb_config"), + Err(err) => tracing::error!("failed to update cosmic-comp xkb_config: {}", err), } } } @@ -158,7 +158,7 @@ impl + Send + 'static> Common { continue; }; - log::info!("updating wallpaper for {:?}", output_name); + tracing::info!("updating wallpaper for {:?}", output_name); for (wallpaper_output_name, wallpaper_source) in user_data.bg_state.wallpapers.iter() { if wallpaper_output_name == output_name { @@ -171,7 +171,7 @@ impl + Send + 'static> Common { //TODO: what to do about duplicates? } None => { - log::warn!( + tracing::warn!( "output {}: failed to find wallpaper data for source {:?}", output_name, path @@ -182,7 +182,11 @@ impl + Send + 'static> Common { } BgSource::Color(color) => { //TODO: support color sources - log::warn!("output {}: unsupported source {:?}", output_name, color); + tracing::warn!( + "output {}: unsupported source {:?}", + output_name, + color + ); } } } @@ -234,7 +238,7 @@ impl + Send + 'static> Common { } } } - log::info!("{:?}", self.active_layouts); + tracing::info!("{:?}", self.active_layouts); } } } @@ -299,7 +303,7 @@ impl + Send + 'static> Common { .get(&surface_id) .and_then(|id| self.text_input_ids.get(id)) { - log::info!("focus surface found id {:?}", text_input_id); + tracing::info!("focus surface found id {:?}", text_input_id); return widget::text_input::focus(text_input_id.clone()); } } diff --git a/src/greeter.rs b/src/greeter.rs index 633f9e3..17c0ee2 100644 --- a/src/greeter.rs +++ b/src/greeter.rs @@ -5,6 +5,7 @@ mod ipc; use crate::wayland::{self, WaylandUpdate}; use cctk::sctk::reexports::calloop; +use color_eyre::eyre::WrapErr; use cosmic::app::{Core, Settings, Task}; use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity; use cosmic::iced::event::listen_with; @@ -56,6 +57,9 @@ use std::{ }; use tokio::process::Child; use tokio::time; +use tracing::metadata::LevelFilter; +use tracing::warn; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; use wayland_client::{Proxy, protocol::wl_output::WlOutput}; use zbus::{Connection, proxy}; @@ -111,7 +115,35 @@ fn user_data_fallback() -> Vec { } pub fn main() -> Result<(), Box> { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); + color_eyre::install().wrap_err("failed to install color_eyre error handler")?; + + let trace = tracing_subscriber::registry(); + let env_filter = EnvFilter::builder() + .with_default_directive(LevelFilter::WARN.into()) + .from_env_lossy(); + + #[cfg(feature = "systemd")] + if let Ok(journald) = tracing_journald::layer() { + trace + .with(journald) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; + } else { + trace + .with(fmt::layer()) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; + warn!("failed to connect to journald") + } + + #[cfg(not(feature = "systemd"))] + trace + .with(fmt::layer()) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; crate::localize::localize(); let runtime = tokio::runtime::Builder::new_current_thread() @@ -121,7 +153,7 @@ pub fn main() -> Result<(), Box> { let mut user_datas = match runtime.block_on(user_data_dbus()) { Ok(ok) => ok, Err(err) => { - log::error!("failed to load user data from daemon: {}", err); + tracing::error!("failed to load user data from daemon: {}", err); user_data_fallback() } }; @@ -163,7 +195,7 @@ pub fn main() -> Result<(), Box> { let read_dir = match fs::read_dir(&session_dir) { Ok(ok) => ok, Err(err) => { - log::warn!( + tracing::warn!( "failed to read session directory {:?}: {:?}", session_dir, err @@ -176,7 +208,7 @@ pub fn main() -> Result<(), Box> { let dir_entry = match dir_entry_res { Ok(ok) => ok, Err(err) => { - log::warn!( + tracing::warn!( "failed to read session directory {:?} entry: {:?}", session_dir, err @@ -188,7 +220,7 @@ pub fn main() -> Result<(), Box> { let entry = match freedesktop_entry_parser::parse_entry(dir_entry.path()) { Ok(ok) => ok, Err(err) => { - log::warn!( + tracing::warn!( "failed to read session file {:?}: {:?}", dir_entry.path(), err @@ -200,7 +232,7 @@ pub fn main() -> Result<(), Box> { let name = match entry.section("Desktop Entry").attr("Name") { Some(some) => some, None => { - log::warn!( + tracing::warn!( "failed to read session file {:?}: no Desktop Entry/Name attribute", dir_entry.path() ); @@ -211,7 +243,7 @@ pub fn main() -> Result<(), Box> { let exec = match entry.section("Desktop Entry").attr("Exec") { Some(some) => some, None => { - log::warn!( + tracing::warn!( "failed to read session file {:?}: no Desktop Entry/Exec attribute", dir_entry.path() ); @@ -254,7 +286,7 @@ pub fn main() -> Result<(), Box> { } } None => { - log::warn!( + tracing::warn!( "failed to parse session file {:?} Exec field {:?}", dir_entry.path(), exec @@ -263,10 +295,10 @@ pub fn main() -> Result<(), Box> { } }; - log::info!("session {} using command {:?} env {:?}", name, command, env); + tracing::info!("session {} using command {:?} env {:?}", name, command, env); match sessions.insert(name.to_string(), (command, env)) { Some(some) => { - log::warn!("session {} overwrote old command {:?}", name, some); + tracing::warn!("session {} overwrote old command {:?}", name, some); } None => {} } @@ -454,16 +486,16 @@ impl App { if let Some(mut stdin) = p.stdin.take() { if let Err(err) = stdin.write_all(kdl_doc.as_bytes()).await { - log::error!("Failed to write KDL to stdin: {err:?}"); + tracing::error!("Failed to write KDL to stdin: {err:?}"); } if let Err(err) = stdin.flush().await { - log::error!("Failed to flush stdin: {err:?}"); + tracing::error!("Failed to flush stdin: {err:?}"); } } - log::debug!("executing {task:?}"); + tracing::debug!("executing {task:?}"); let status = p.wait().await; if let Err(err) = status { - log::error!("Randr error: {err:?}"); + tracing::error!("Randr error: {err:?}"); } }) .discard() @@ -1097,7 +1129,7 @@ impl cosmic::Application for App { Message::OutputEvent(output_event, output) => { match output_event { OutputEvent::Created(output_info_opt) => { - log::info!("output {}: created", output.id()); + tracing::info!("output {}: created", output.id()); let surface_id = SurfaceId::unique(); let subsurface_id = SurfaceId::unique(); @@ -1107,7 +1139,7 @@ impl cosmic::Application for App { match self.common.surface_ids.insert(output.clone(), surface_id) { Some(old_surface_id) => { //TODO: remove old surface? - log::warn!( + tracing::warn!( "output {}: already had surface ID {:?}", output.id(), old_surface_id @@ -1139,11 +1171,11 @@ impl cosmic::Application for App { .insert(output_name.clone(), text_input_id.clone()); } None => { - log::warn!("output {}: no output name", output.id()); + tracing::warn!("output {}: no output name", output.id()); } }, None => { - log::warn!("output {}: no output info", output.id()); + tracing::warn!("output {}: no output info", output.id()); } } @@ -1208,7 +1240,7 @@ impl cosmic::Application for App { ]); } OutputEvent::Removed => { - log::info!("output {}: removed", output.id()); + tracing::info!("output {}: removed", output.id()); match self.common.surface_ids.remove(&output) { Some(surface_id) => { self.common.surface_images.remove(&surface_id); @@ -1219,12 +1251,12 @@ impl cosmic::Application for App { return destroy_layer_surface(surface_id); } None => { - log::warn!("output {}: no surface found", output.id()); + tracing::warn!("output {}: no surface found", output.id()); } } } OutputEvent::InfoUpdate(_output_info) => { - log::info!("output {}: info update", output.id()); + tracing::info!("output {}: info update", output.id()); } } } @@ -1319,7 +1351,7 @@ impl cosmic::Application for App { .map(|uid| self.flags.greeter_config.users.entry(uid)) }) }) else { - log::error!( + tracing::error!( "Couldn't find user: {:?} {:?}", self.selected_username.username, self.selected_username.data_idx, @@ -1328,7 +1360,7 @@ impl cosmic::Application for App { }; let Some(handler) = self.flags.greeter_config_handler.as_mut() else { - log::error!( + tracing::error!( "Failed to update config for {} (UID: {}): no config handler", self.selected_username.username, user_entry.key() @@ -1339,7 +1371,7 @@ impl cosmic::Application for App { let uid = *user_entry.key(); self.flags.greeter_config.last_user = Some(uid); if let Err(err) = handler.set("last_user", &self.flags.greeter_config.last_user) { - log::error!( + tracing::error!( "Failed to set {:?} as last user: {:?}", self.flags.greeter_config.last_user, err @@ -1376,7 +1408,7 @@ impl cosmic::Application for App { // .greeter_config // .set_users(&handler, self.flags.greeter_config.users.clone()) if let Err(err) = handler.set("users", &self.flags.greeter_config.users) { - log::error!( + tracing::error!( "Failed to set {} as last selected session for {} (UID: {}): {:?}", self.selected_session, self.selected_username.username, @@ -1421,7 +1453,7 @@ impl cosmic::Application for App { match crate::logind::reboot().await { Ok(()) => (), Err(err) => { - log::error!("failed to reboot: {:?}", err); + tracing::error!("failed to reboot: {:?}", err); } } }) @@ -1433,7 +1465,7 @@ impl cosmic::Application for App { match crate::logind::power_off().await { Ok(()) => (), Err(err) => { - log::error!("failed to power off: {:?}", err); + tracing::error!("failed to power off: {:?}", err); } } }) @@ -1463,7 +1495,7 @@ impl cosmic::Application for App { match crate::logind::suspend().await { Ok(()) => (), Err(err) => { - log::error!("failed to suspend: {:?}", err); + tracing::error!("failed to suspend: {:?}", err); } } }) @@ -1543,7 +1575,7 @@ impl cosmic::Application for App { if let Some(mut c) = self.accessibility.screen_reader.take() { return cosmic::task::future::<(), ()>(async move { if let Err(err) = c.kill().await { - log::error!("Failed to stop screen reader: {err:?}"); + tracing::error!("Failed to stop screen reader: {err:?}"); } }) .discard(); @@ -1590,7 +1622,7 @@ impl cosmic::Application for App { _ = tx.send(Some(t)); } Err(err) => { - log::error!("{err:?}"); + tracing::error!("{err:?}"); _ = tx.send(None); } }); @@ -1672,7 +1704,7 @@ impl cosmic::Application for App { .filter_map(|s| match KdlDocument::parse(s) { Ok(doc) => Some(doc), Err(err) => { - log::warn!("Invalid output KDL {err:?}"); + tracing::warn!("Invalid output KDL {err:?}"); None } }) @@ -1680,7 +1712,7 @@ impl cosmic::Application for App { Ok(list) => list, Err(KdlParseWithError { list, errors }) => { for err in errors { - log::warn!("KDL output error: {err:?}"); + tracing::warn!("KDL output error: {err:?}"); } list } @@ -1709,13 +1741,13 @@ impl cosmic::Application for App { if let Some(list) = list { tasks.push(self.exec_randr(list)) } else { - log::warn!("Failed to apply user display config"); + tracing::warn!("Failed to apply user display config"); } return Task::batch(tasks); } Err(err) => { - log::error!("Randr error: {err}"); + tracing::error!("Randr error: {err}"); } }, Message::RepositionMenu(id, size) => { @@ -1724,7 +1756,7 @@ impl cosmic::Application for App { .iter() .find_map(|(p, s)| (*p == id).then_some(s)) else { - log::error!("Failed to find subsurface menu id"); + tracing::error!("Failed to find subsurface menu id"); return Task::none(); }; let loc = if size.width > 800. { diff --git a/src/greeter/ipc.rs b/src/greeter/ipc.rs index 17e498c..103f98a 100644 --- a/src/greeter/ipc.rs +++ b/src/greeter/ipc.rs @@ -31,7 +31,7 @@ pub fn subscription() -> Subscription { let mut stream = match UnixStream::connect(&socket_path).await { Ok(stream) => stream, Err(why) => { - log::error!("greetd IPC socket connection failed: {why:?}"); + tracing::error!("greetd IPC socket connection failed: {why:?}"); _ = sender.send(Message::Socket(SocketState::Error(Arc::new(why)))); break; @@ -42,7 +42,7 @@ pub fn subscription() -> Subscription { while let Some(request) = rx.recv().await { if let Err(why) = request.write_to(&mut stream).await { - log::error!("error writing to GREETD_SOCK stream: {why:?}"); + tracing::error!("error writing to GREETD_SOCK stream: {why:?}"); break; } @@ -96,7 +96,7 @@ pub fn subscription() -> Subscription { match request { greetd_ipc::Request::CancelSession => { // Do not send errors for cancel session to gui - log::warn!( + tracing::warn!( "error while cancelling session: {}", description ); @@ -123,7 +123,7 @@ pub fn subscription() -> Subscription { _ = sender.send(Message::Exit).await; } greetd_ipc::Request::CancelSession => { - log::info!("greetd IPC session canceled"); + tracing::info!("greetd IPC session canceled"); // Reconnect to socket break; } @@ -131,13 +131,13 @@ pub fn subscription() -> Subscription { } } Err(err) => { - log::error!("failed to read socket: {:?}", err); + tracing::error!("failed to read socket: {:?}", err); break; } } } - log::info!("reconnecting to greetd IPC socket"); + tracing::info!("reconnecting to greetd IPC socket"); interval.tick().await; } diff --git a/src/locker.rs b/src/locker.rs index c58f5f8..81dead9 100644 --- a/src/locker.rs +++ b/src/locker.rs @@ -1,6 +1,7 @@ // Copyright 2023 System76 // SPDX-License-Identifier: GPL-3.0-only +use color_eyre::eyre::WrapErr; use cosmic::app::{Core, Settings, Task}; use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity; use cosmic::iced::{Point, Rectangle, Size}; @@ -33,6 +34,9 @@ use std::{ sync::Arc, }; use tokio::{sync::mpsc, task}; +use tracing::level_filters::LevelFilter; +use tracing::warn; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; use wayland_client::{Proxy, protocol::wl_output::WlOutput}; use crate::{ @@ -47,7 +51,35 @@ fn lockfile_opt() -> Option { } pub fn main(user: pwd::Passwd) -> Result<(), Box> { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); + color_eyre::install().wrap_err("failed to install color_eyre error handler")?; + + let trace = tracing_subscriber::registry(); + let env_filter = EnvFilter::builder() + .with_default_directive(LevelFilter::WARN.into()) + .from_env_lossy(); + + #[cfg(feature = "systemd")] + if let Ok(journald) = tracing_journald::layer() { + trace + .with(journald) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; + } else { + trace + .with(fmt::layer()) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; + warn!("failed to connect to journald") + } + + #[cfg(not(feature = "systemd"))] + trace + .with(fmt::layer()) + .with(env_filter) + .try_init() + .wrap_err("failed to initialize logger")?; crate::localize::localize(); @@ -74,11 +106,11 @@ pub fn pam_thread(username: String, conversation: Conversation) -> Result<(), pa let mut context = pam_client::Context::new("cosmic-greeter", Some(&username), conversation)?; // Authenticate the user (ask for password, 2nd-factor token, fingerprint, etc.) - log::info!("authenticate"); + tracing::info!("authenticate"); context.authenticate(pam_client::Flag::NONE)?; // Validate the account (is not locked, expired, etc.) - log::info!("acct_mgmt"); + tracing::info!("acct_mgmt"); context.acct_mgmt(pam_client::Flag::NONE)?; Ok(()) @@ -96,7 +128,7 @@ impl Conversation { secret: bool, ) -> Result { let prompt = prompt_c.to_str().map_err(|err| { - log::error!("failed to convert prompt to UTF-8: {:?}", err); + tracing::error!("failed to convert prompt to UTF-8: {:?}", err); pam_client::ErrorCode::CONV_ERR })?; @@ -108,24 +140,24 @@ impl Conversation { .await }) .map_err(|err| { - log::error!("failed to send prompt: {:?}", err); + tracing::error!("failed to send prompt: {:?}", err); pam_client::ErrorCode::CONV_ERR })?; let value = self.value_rx.blocking_recv().ok_or_else(|| { - log::error!("failed to receive value: channel closed"); + tracing::error!("failed to receive value: channel closed"); pam_client::ErrorCode::CONV_ERR })?; CString::new(value).map_err(|err| { - log::error!("failed to convert value to C string: {:?}", err); + tracing::error!("failed to convert value to C string: {:?}", err); pam_client::ErrorCode::CONV_ERR }) } fn message(&mut self, prompt_c: &CStr) -> Result<(), pam_client::ErrorCode> { let prompt = prompt_c.to_str().map_err(|err| { - log::error!("failed to convert prompt to UTF-8: {:?}", err); + tracing::error!("failed to convert prompt to UTF-8: {:?}", err); pam_client::ErrorCode::CONV_ERR })?; @@ -137,7 +169,7 @@ impl Conversation { .await }) .map_err(|err| { - log::error!("failed to send prompt: {:?}", err); + tracing::error!("failed to send prompt: {:?}", err); pam_client::ErrorCode::CONV_ERR }) } @@ -145,29 +177,29 @@ impl Conversation { impl pam_client::ConversationHandler for Conversation { fn prompt_echo_on(&mut self, prompt_c: &CStr) -> Result { - log::info!("prompt_echo_on {:?}", prompt_c); + tracing::info!("prompt_echo_on {:?}", prompt_c); self.prompt_value(prompt_c, false) } fn prompt_echo_off(&mut self, prompt_c: &CStr) -> Result { - log::info!("prompt_echo_off {:?}", prompt_c); + tracing::info!("prompt_echo_off {:?}", prompt_c); self.prompt_value(prompt_c, true) } fn text_info(&mut self, prompt_c: &CStr) { - log::info!("text_info {:?}", prompt_c); + tracing::info!("text_info {:?}", prompt_c); match self.message(prompt_c) { Ok(()) => (), Err(err) => { - log::warn!("failed to send text_info: {:?}", err); + tracing::warn!("failed to send text_info: {:?}", err); } } } fn error_msg(&mut self, prompt_c: &CStr) { //TODO: treat error type differently? - log::info!("error_msg {:?}", prompt_c); + tracing::info!("error_msg {:?}", prompt_c); match self.message(prompt_c) { Ok(()) => (), Err(err) => { - log::warn!("failed to send error_msg: {:?}", err); + tracing::warn!("failed to send error_msg: {:?}", err); } } } @@ -226,7 +258,7 @@ impl Drop for State { fn drop(&mut self) { // Abort the locked task when the state is changed. if let Self::Locked { task_handle } = self { - log::info!("dropping lockscreen tasks"); + tracing::info!("dropping lockscreen tasks"); task_handle.abort(); } } @@ -542,7 +574,7 @@ impl cosmic::Application for App { let task = if cfg!(feature = "logind") { if already_locked { // Recover previously locked state - log::info!("recovering previous locked state"); + tracing::info!("recovering previous locked state"); app.state = State::Locking; lock() } else { @@ -551,7 +583,7 @@ impl cosmic::Application for App { } } else { // When logind feature not used, lock immediately - log::info!("locking immediately"); + tracing::info!("locking immediately"); app.state = State::Locking; lock() }; @@ -569,7 +601,7 @@ impl cosmic::Application for App { Message::OutputEvent(output_event, output) => { match output_event { OutputEvent::Created(output_info_opt) => { - log::info!("output {}: created", output.id()); + tracing::info!("output {}: created", output.id()); let surface_id = SurfaceId::unique(); let subsurface_id = SurfaceId::unique(); @@ -578,7 +610,7 @@ impl cosmic::Application for App { self.common.surface_ids.insert(output.clone(), surface_id) { //TODO: remove old surface? - log::warn!( + tracing::warn!( "output {}: already had surface ID {:?}", output.id(), old_surface_id @@ -614,11 +646,11 @@ impl cosmic::Application for App { .insert(output_name.clone(), text_input_id.clone()); } None => { - log::warn!("output {}: no output name", output.id()); + tracing::warn!("output {}: no output name", output.id()); } }, None => { - log::warn!("output {}: no output info", output.id()); + tracing::warn!("output {}: no output info", output.id()); } } @@ -672,7 +704,7 @@ impl cosmic::Application for App { } } OutputEvent::Removed => { - log::info!("output {}: removed", output.id()); + tracing::info!("output {}: removed", output.id()); match self.common.surface_ids.remove(&output) { Some(surface_id) => { self.common.surface_images.remove(&surface_id); @@ -686,7 +718,7 @@ impl cosmic::Application for App { } } None => { - log::warn!("output {}: no surface found", output.id()); + tracing::warn!("output {}: no surface found", output.id()); } } } @@ -711,14 +743,14 @@ impl cosmic::Application for App { .subsurface_rects .insert(output.clone(), Rectangle::new(loc, sub_size)); - log::info!("output {}: info update", output.id()); + tracing::info!("output {}: info update", output.id()); } } } Message::SessionLockEvent(session_lock_event) => match session_lock_event { SessionLockEvent::Focused(..) => {} SessionLockEvent::Locked => { - log::info!("session locked"); + tracing::info!("session locked"); if matches!(self.state, State::Locked { .. }) { return Task::none(); } @@ -764,7 +796,7 @@ impl cosmic::Application for App { match pam_res { Ok(()) => { - log::info!("successfully authenticated"); + tracing::info!("successfully authenticated"); msg_tx .send(cosmic::Action::App(Message::Unlock)) .await @@ -772,7 +804,7 @@ impl cosmic::Application for App { break; } Err(err) => { - log::warn!("authentication error: {}", err); + tracing::warn!("authentication error: {}", err); msg_tx .send(cosmic::Action::App(Message::Error( err.to_string(), @@ -838,13 +870,13 @@ impl cosmic::Application for App { cosmic::app::Action::Surface(msg), ))); } else { - log::error!("no rectangle for subsurface..."); + tracing::error!("no rectangle for subsurface..."); } } return Task::batch(commands); } SessionLockEvent::Unlocked => { - log::info!("session unlocked"); + tracing::info!("session unlocked"); self.state = State::Unlocked; let mut commands = Vec::new(); @@ -883,7 +915,7 @@ impl cosmic::Application for App { } Message::Inhibit(inhibit) => match self.state { State::Locked { .. } => { - log::info!("no need to inhibit sleep when already locked"); + tracing::info!("no need to inhibit sleep when already locked"); } _ => { self.inhibit_opt = Some(inhibit); @@ -910,14 +942,14 @@ impl cosmic::Application for App { Message::Channel(value_tx) }); } - None => log::warn!("tried to submit when value_tx_opt not set"), + None => tracing::warn!("tried to submit when value_tx_opt not set"), } } Message::Suspend => { #[cfg(feature = "logind")] return cosmic::Task::future(async move { crate::logind::suspend().await.err() }) .and_then(|err| { - log::error!("failed to suspend: {:?}", err); + tracing::error!("failed to suspend: {:?}", err); cosmic::task::message(cosmic::Action::App(Message::Error(err.to_string()))) }); } @@ -929,7 +961,7 @@ impl cosmic::Application for App { } Message::Lock => match self.state { State::Unlocked => { - log::info!("session locking"); + tracing::info!("session locking"); self.state = State::Locking; // Clear errors self.common.error_opt = None; @@ -938,23 +970,23 @@ impl cosmic::Application for App { // Try to create lockfile when locking if let Some(ref lockfile) = self.flags.lockfile_opt { if let Err(err) = fs::File::create(lockfile) { - log::warn!("failed to create lockfile {:?}: {}", lockfile, err); + tracing::warn!("failed to create lockfile {:?}: {}", lockfile, err); } } // Tell compositor to lock return lock(); } State::Unlocking => { - log::info!("session still unlocking"); + tracing::info!("session still unlocking"); } State::Locking | State::Locked { .. } => { - log::info!("session already locking or locked"); + tracing::info!("session already locking or locked"); } }, Message::Unlock => { match self.state { State::Locked { .. } => { - log::info!("sessing unlocking"); + tracing::info!("sessing unlocking"); self.state = State::Unlocking; // Clear errors self.common.error_opt = None; @@ -963,7 +995,7 @@ impl cosmic::Application for App { // Try to delete lockfile when unlocking if let Some(ref lockfile) = self.flags.lockfile_opt { if let Err(err) = fs::remove_file(lockfile) { - log::warn!("failed to remove lockfile {:?}: {}", lockfile, err); + tracing::warn!("failed to remove lockfile {:?}: {}", lockfile, err); } } @@ -983,10 +1015,10 @@ impl cosmic::Application for App { return Task::batch(commands); } State::Locking => { - log::info!("session still locking"); + tracing::info!("session still locking"); } State::Unlocking | State::Unlocked => { - log::info!("session already unlocking or unlocked"); + tracing::info!("session already unlocking or unlocked"); } } } @@ -1032,7 +1064,7 @@ impl cosmic::Application for App { ) .map(|res| { if !res.errors.is_empty() { - log::info!("errors loading background state: {:?}", res.errors); + tracing::info!("errors loading background state: {:?}", res.errors); } Message::BackgroundState(res.config) }), @@ -1047,7 +1079,7 @@ impl cosmic::Application for App { ) .map(|res| { if !res.errors.is_empty() { - log::info!("errors loading background state: {:?}", res.errors); + tracing::info!("errors loading background state: {:?}", res.errors); } Message::TimeAppletConfig(res.config) }), diff --git a/src/logind.rs b/src/logind.rs index fe9f22d..d4f216c 100644 --- a/src/logind.rs +++ b/src/logind.rs @@ -52,7 +52,7 @@ pub fn subscription() -> Subscription { match handler(&mut msg_tx).await { Ok(()) => {} Err(err) => { - log::warn!("logind error: {}", err); + tracing::warn!("logind error: {}", err); //TODO: send error } } @@ -89,13 +89,13 @@ pub async fn handler(msg_tx: &mut mpsc::Sender) -> Result<(), Box match signal.args() { Ok(args) => { if args.start { - log::info!("logind prepare for sleep"); + tracing::info!("logind prepare for sleep"); if let Some(inhibit) = inhibit_opt.take() { msg_tx.send(Message::Inhibit(Arc::new(inhibit))).await?; } msg_tx.send(Message::Lock).await?; } else { - log::info!("logind resume"); + tracing::info!("logind resume"); if inhibit_opt.is_none() { inhibit_opt = Some(inhibit(&manager).await?); } @@ -104,19 +104,19 @@ pub async fn handler(msg_tx: &mut mpsc::Sender) -> Result<(), Box { - log::warn!("logind prepare to sleep invalid data: {}", err); + tracing::warn!("logind prepare to sleep invalid data: {}", err); } }, None => { - log::warn!("logind prepare to sleep missing data"); + tracing::warn!("logind prepare to sleep missing data"); } } }, _ = lock.next() => { - log::info!("logind lock"); + tracing::info!("logind lock"); msg_tx.send(Message::Lock).await?; }, _ = unlock.next() => { - log::info!("logind unlock"); + tracing::info!("logind unlock"); msg_tx.send(Message::Unlock).await?; }); diff --git a/src/networkmanager.rs b/src/networkmanager.rs index a4635ef..173ce39 100644 --- a/src/networkmanager.rs +++ b/src/networkmanager.rs @@ -42,7 +42,7 @@ pub fn subscription() -> Subscription> { match handler(&mut msg_tx).await { Ok(()) => {} Err(err) => { - log::warn!("networkmanager error: {}", err); + tracing::warn!("networkmanager error: {}", err); //TODO: send error } } diff --git a/src/time.rs b/src/time.rs index ba24bdd..1c3768d 100644 --- a/src/time.rs +++ b/src/time.rs @@ -47,7 +47,7 @@ impl Time { let locale = match get_local() { Ok(locale) => locale, Err(e) => { - log::error!("can't get locale {e}"); + tracing::error!("can't get locale {e}"); Locale::default() } }; @@ -136,7 +136,7 @@ pub fn tz_updates() -> Task { Task::stream(async_fn_stream::fn_stream(|emitter| async move { loop { if let Err(err) = tz_stream(&emitter).await { - log::error!("{err:?}"); + tracing::error!("{err:?}"); } _ = time::sleep(Duration::from_secs(60)).await; } diff --git a/src/upower.rs b/src/upower.rs index 0fdbe2c..0ad5788 100644 --- a/src/upower.rs +++ b/src/upower.rs @@ -15,7 +15,7 @@ pub fn subscription() -> Subscription> { match handler(&mut msg_tx).await { Ok(()) => {} Err(err) => { - log::warn!("upower error: {}", err); + tracing::warn!("upower error: {}", err); //TODO: send error } }