From d5e431d37e21e38532887c969e650040b2175229 Mon Sep 17 00:00:00 2001 From: nevaforget Date: Sat, 28 Mar 2026 22:56:39 +0100 Subject: [PATCH] fix: make setup_logging() resilient to journal logger failure (v0.5.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace unwrap() calls with match-based error handling that falls back to eprintln — prevents panic when running outside a systemd session. Consistent with moonlock's logging init pattern. --- Cargo.toml | 2 +- src/main.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7921612..e305c7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "moongreet" -version = "0.5.0" +version = "0.5.1" edition = "2024" description = "A greetd greeter for Wayland with GTK4 and Layer Shell" license = "MIT" diff --git a/src/main.rs b/src/main.rs index a70331c..7ceb185 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,10 +92,16 @@ fn activate(app: >k::Application) { } fn setup_logging() { - systemd_journal_logger::JournalLog::new() - .unwrap() - .install() - .unwrap(); + match systemd_journal_logger::JournalLog::new() { + Ok(logger) => { + if let Err(e) = logger.install() { + eprintln!("Failed to install journal logger: {e}"); + } + } + Err(e) => { + eprintln!("Failed to create journal logger: {e}"); + } + } let level = if std::env::var("MOONGREET_DEBUG").is_ok() { log::LevelFilter::Debug } else {