From b0c05a344be91adb6e585694bc117528dfe22cff Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 18 Jan 2024 18:16:37 -0500 Subject: [PATCH 1/5] fix: logging and use dbus config subscription in audio applet --- Cargo.lock | 126 +++--------------- Cargo.toml | 2 + cosmic-app-list/Cargo.toml | 3 +- cosmic-app-list/src/main.rs | 3 +- cosmic-applet-audio/Cargo.toml | 10 +- cosmic-applet-audio/src/main.rs | 8 +- cosmic-applet-battery/Cargo.toml | 3 +- cosmic-applet-battery/src/main.rs | 3 +- cosmic-applet-bluetooth/Cargo.toml | 3 +- cosmic-applet-bluetooth/src/main.rs | 3 +- cosmic-applet-network/Cargo.toml | 3 +- cosmic-applet-network/src/main.rs | 3 +- cosmic-applet-notifications/Cargo.toml | 3 +- cosmic-applet-notifications/src/main.rs | 1 + cosmic-applet-workspaces/Cargo.toml | 5 +- .../src/components/app.rs | 2 - cosmic-applet-workspaces/src/config.rs | 2 - cosmic-applet-workspaces/src/main.rs | 15 ++- debian/control | 2 +- rust-toolchain.toml | 2 +- 20 files changed, 63 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1770fcdc..6efd396c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -410,17 +410,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -772,7 +761,6 @@ dependencies = [ "log", "nix 0.26.4", "once_cell", - "pretty_env_logger 0.5.0", "rand", "ron", "rust-embed 6.8.1", @@ -780,28 +768,30 @@ dependencies = [ "serde", "shlex", "tokio", + "tracing-log", + "tracing-subscriber", "url", "xdg", ] [[package]] name = "cosmic-applet-audio" -version = "0.1.0" +version = "0.1.1" dependencies = [ "cosmic-time", "i18n-embed 0.13.9", "i18n-embed-fl 0.6.7", - "icon-loader", "libcosmic", "libpulse-binding", "libpulse-glib-binding", "mpris2-zbus", - "pretty_env_logger 0.4.0", "rust-embed 6.8.1", "rust-embed-utils 7.8.1", "serde", "tokio", "tracing", + "tracing-log", + "tracing-subscriber", "url", "zbus", ] @@ -817,10 +807,11 @@ dependencies = [ "libcosmic", "log", "once_cell", - "pretty_env_logger 0.5.0", "rust-embed 6.8.1", "tokio", "tracing", + "tracing-log", + "tracing-subscriber", "zbus", ] @@ -839,11 +830,12 @@ dependencies = [ "libcosmic", "log", "once_cell", - "pretty_env_logger 0.5.0", "rand", "rust-embed 6.8.1", "slotmap", "tokio", + "tracing-log", + "tracing-subscriber", ] [[package]] @@ -873,11 +865,12 @@ dependencies = [ "itertools 0.10.5", "libcosmic", "log", - "pretty_env_logger 0.5.0", "rust-embed 6.8.1", "rust-embed-utils 7.8.1", "slotmap", "tokio", + "tracing-log", + "tracing-subscriber", "zbus", ] @@ -900,6 +893,7 @@ dependencies = [ "sendfd", "tokio", "tracing", + "tracing-log", "tracing-subscriber", "url", "zbus", @@ -965,7 +959,7 @@ dependencies = [ [[package]] name = "cosmic-applet-workspaces" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "cosmic-client-toolkit", @@ -977,8 +971,9 @@ dependencies = [ "log", "nix 0.26.4", "once_cell", - "pretty_env_logger 0.5.0", "rust-embed 6.8.1", + "tracing-log", + "tracing-subscriber", "xdg", ] @@ -1633,32 +1628,6 @@ dependencies = [ "syn 2.0.40", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "env_logger" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" -dependencies = [ - "humantime 2.1.0", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -2425,15 +2394,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.3" @@ -2452,21 +2412,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "i18n-config" version = "0.4.6" @@ -2909,7 +2854,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "libc", "windows-sys 0.48.0", ] @@ -2920,17 +2865,6 @@ version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a611371471e98973dbcab4e0ec66c31a10bc356eeb4d54a0e05eac8158fe38c" -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.3", - "rustix 0.38.28", - "windows-sys 0.48.0", -] - [[package]] name = "itertools" version = "0.10.5" @@ -3611,7 +3545,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "libc", ] @@ -3973,26 +3907,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" -[[package]] -name = "pretty_env_logger" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" -dependencies = [ - "env_logger 0.7.1", - "log", -] - -[[package]] -name = "pretty_env_logger" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" -dependencies = [ - "env_logger 0.10.1", - "log", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -4083,12 +3997,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quick-xml" version = "0.28.2" diff --git a/Cargo.toml b/Cargo.toml index 01acf11c..daa7c4db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,8 @@ libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = fa ] } zbus = { version = "3.14", default-features = false, features = ["tokio"] } tracing = "0.1" +tracing-subscriber = "0.3.18" +tracing-log = "0.2.0" [profile.release] lto = "thin" diff --git a/cosmic-app-list/Cargo.toml b/cosmic-app-list/Cargo.toml index 9dc3d0bd..764b9026 100644 --- a/cosmic-app-list/Cargo.toml +++ b/cosmic-app-list/Cargo.toml @@ -14,7 +14,8 @@ futures = "0.3" futures-util = "0.3" once_cell = "1.9" xdg = "2.4" -pretty_env_logger = "0.5" +tracing-subscriber.workspace = true +tracing-log.workspace = true nix = "0.26" shlex = "1.1.0" anyhow = "1.0" diff --git a/cosmic-app-list/src/main.rs b/cosmic-app-list/src/main.rs index ab85a26d..e46afc57 100644 --- a/cosmic-app-list/src/main.rs +++ b/cosmic-app-list/src/main.rs @@ -14,7 +14,8 @@ use crate::config::{APP_ID, VERSION}; fn main() -> cosmic::iced::Result { // Initialize logger - pretty_env_logger::init(); + tracing_subscriber::fmt::init(); + let _ = tracing_log::LogTracer::init(); info!("Iced Workspaces Applet ({})", APP_ID); info!("Version: {}", VERSION); // Prepare i18n diff --git a/cosmic-applet-audio/Cargo.toml b/cosmic-applet-audio/Cargo.toml index 56488da8..2c854d65 100644 --- a/cosmic-applet-audio/Cargo.toml +++ b/cosmic-applet-audio/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "cosmic-applet-audio" -version = "0.1.0" +version = "0.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -icon-loader = { version = "0.3.6", features = ["gtk"] } -libpulse-binding = "2.26.0" -libpulse-glib-binding = "2.25.0" +libpulse-binding = "2.28.1" +libpulse-glib-binding = "2.28.1" tokio = { version = "1.20.1", features=["full"] } libcosmic.workspace = true cosmic-time.workspace = true tracing = "0.1.40" -pretty_env_logger = "0.4.0" +tracing-subscriber.workspace = true +tracing-log.workspace = true # Application i18n i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] } i18n-embed-fl = "0.6" diff --git a/cosmic-applet-audio/src/main.rs b/cosmic-applet-audio/src/main.rs index 4d5943b8..b45cac69 100644 --- a/cosmic-applet-audio/src/main.rs +++ b/cosmic-applet-audio/src/main.rs @@ -40,12 +40,18 @@ use mpris_subscription::MprisUpdate; mod config; mod mpris_subscription; mod pulse; + +const VERSION: &str = env!("CARGO_PKG_VERSION"); + pub fn main() -> cosmic::iced::Result { - pretty_env_logger::init(); + tracing_subscriber::fmt::init(); + let _ = tracing_log::LogTracer::init(); // Prepare i18n localize(); + tracing::info!("Starting audio applet with version {VERSION}"); + cosmic::applet::run::