fjordgard

A desktop clock application
Log | Files | Refs | README | LICENSE

commit 2a0b10569cea455ad7e3d615bf46d8aff4530e0e
parent 9a4456496275c4fcc7d3fe4efef2f867216bc1ae
Author: Sylvia Ivory <git@sivory.net>
Date:   Thu, 19 Jun 2025 00:52:01 -0700

Add logging

Diffstat:
MCargo.lock | 176+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MCargo.toml | 2++
Msrc/background.rs | 9+++++++--
Msrc/main.rs | 11+++++++++++
Msrc/settings.rs | 6++++--
5 files changed, 200 insertions(+), 4 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -58,6 +58,15 @@ dependencies = [ ] [[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] name = "allocator-api2" version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -106,6 +115,56 @@ dependencies = [ ] [[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.59.0", +] + +[[package]] name = "approx" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -603,6 +662,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] name = "com" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1094,6 +1159,29 @@ dependencies = [ ] [[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1196,8 +1284,10 @@ name = "fjordgard" version = "0.1.0" dependencies = [ "chrono", + "env_logger", "fjordgard-weather", "iced", + "log", "rfd", "strum", "tokio", @@ -2221,12 +2311,42 @@ dependencies = [ ] [[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] +name = "jiff" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.103", +] + +[[package]] name = "jni" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2981,6 +3101,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] name = "openssl" version = "0.10.73" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3284,6 +3410,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" [[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] name = "potential_utf" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3536,6 +3677,35 @@ dependencies = [ ] [[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] name = "renderdoc-sys" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4752,6 +4922,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -11,8 +11,10 @@ edition = "2024" [dependencies] chrono = "0.4.41" +env_logger = "0.11.8" fjordgard-weather = { version = "0.1.0", path = "crates/weather" } iced = { version = "0.13.1", features = ["tokio", "canvas", "image", "svg"] } +log = "0.4.27" rfd = "0.15.3" strum = { version = "0.27.1", features = ["derive"] } tokio = { version = "1.45.1", features = ["full"] } diff --git a/src/background.rs b/src/background.rs @@ -2,6 +2,7 @@ use iced::{ Color, ContentFit, Element, Length, Point, Renderer, Size, Task, Theme, mouse, widget::{canvas, container, image, stack, text}, }; +use log::{debug, error}; use tokio::fs; use crate::config::{BackgroundMode, Config}; @@ -64,6 +65,8 @@ impl BackgroundHandle { } fn refresh(&mut self) -> Task<Message> { + debug!("refreshing background (mode={}, background={})", self.mode, &self.background); + match self.mode { BackgroundMode::Local => { let path = self.background.clone(); @@ -78,8 +81,10 @@ impl BackgroundHandle { pub fn update(&mut self, msg: Message) -> Task<Message> { match msg { Message::BackgroundRead(res) => match res { - // TODO; log error - Err(_) => Task::none(), + Err(e) => { + error!("failed to load image: {e}"); + Task::none() + }, Ok(bytes) => { self.image_handle = Some(image::Handle::from_bytes(bytes)); Task::none() diff --git a/src/main.rs b/src/main.rs @@ -16,6 +16,7 @@ use iced::{ use background::BackgroundHandle; use config::Config; use icon::{icon, icon_button}; +use log::debug; use crate::config::BackgroundMode; @@ -153,6 +154,14 @@ impl Fjordgard { } } Message::Background(msg) => self.background.update(msg).map(Message::Background), + Message::SettingsOpened => { + debug!("settings window opened"); + Task::none() + }, + Message::MainWindowOpened => { + debug!("main window opened"); + Task::none() + } _ => Task::none(), } } @@ -224,6 +233,8 @@ impl Fjordgard { } fn main() -> iced::Result { + env_logger::init(); + iced::daemon(Fjordgard::title, Fjordgard::update, Fjordgard::view) .subscription(Fjordgard::subscription) .run_with(Fjordgard::new) diff --git a/src/settings.rs b/src/settings.rs @@ -5,6 +5,7 @@ use iced::{ Background, Border, Color, Element, Length, Task, Theme, widget::{button, column, combo_box, container, row, scrollable, text, text_input, tooltip}, }; +use log::error; use rfd::{AsyncFileDialog, FileHandle}; use strum::VariantArray; @@ -145,8 +146,9 @@ impl Settings { } Message::Geocode(locations) => { match locations { - Err(s) => { - self.location_fetch_error = Some(s); + Err(e) => { + error!("failed to fetch geocode: {e}"); + self.location_fetch_error = Some(e); } Ok(res) => { self.location_results = res