From 3d55cba06c9cf6f27609cdefb520f7857dba20af Mon Sep 17 00:00:00 2001 From: "Anthony T. Lannutti" Date: Sat, 13 Jun 2026 16:33:51 -0500 Subject: [PATCH] feat: make tracing-journald dependency optional Fixes #2466 --- Cargo.toml | 4 ++-- src/logger/mod.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index feb02259..288b4069 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ tracing = { version = "0.1.44", features = [ "max_level_debug", "release_max_level_info", ] } -tracing-journald = "0.3.2" +tracing-journald = { version = "0.3.2", optional = true } tracing-subscriber = { version = "0.3.22", features = [ "env-filter", "tracing-log", @@ -122,7 +122,7 @@ optional = true debug = ["egui", "egui_plot", "smithay-egui", "anyhow/backtrace"] default = ["systemd"] logind = ["logind-zbus"] -systemd = ["libsystemd", "logind"] +systemd = ["libsystemd", "logind", "tracing-journald"] profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client/default"] profile-with-tracy-gpu = ["profile-with-tracy", "smithay/tracy_gpu_profiling"] diff --git a/src/logger/mod.rs b/src/logger/mod.rs index 3e5347df..34baf42d 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -4,7 +4,10 @@ use std::str::FromStr; use anyhow::Result; -use tracing::{debug, info, warn}; +#[cfg(feature = "systemd")] +use tracing::warn; +use tracing::{debug, info}; +#[cfg(feature = "systemd")] use tracing_journald as journald; use tracing_subscriber::{EnvFilter, filter::Directive, fmt, prelude::*}; @@ -29,6 +32,7 @@ pub fn init_logger() -> Result<()> { let fmt_layer = fmt::layer().compact(); + #[cfg(feature = "systemd")] match journald::layer() { Ok(journald_layer) => tracing_subscriber::registry() .with(fmt_layer) @@ -43,6 +47,11 @@ pub fn init_logger() -> Result<()> { warn!(?err, "Failed to init journald logging."); } }; + #[cfg(not(feature = "systemd"))] + tracing_subscriber::registry() + .with(fmt_layer) + .with(filter) + .init(); log_panics::init(); info!("Version: {}", std::env!("CARGO_PKG_VERSION"));