From 8768d70d37eed8901aa2db346fbd586e06618784 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 5 Sep 2025 10:21:01 -0400 Subject: [PATCH] tracing: Log to journal if root The intention was to always log to the systemd journal, even if we're spawned directly on the CLI outside of a unit. Signed-off-by: Colin Walters --- crates/utils/src/tracing_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/utils/src/tracing_util.rs b/crates/utils/src/tracing_util.rs index 38fd561a..0f9f4ed9 100644 --- a/crates/utils/src/tracing_util.rs +++ b/crates/utils/src/tracing_util.rs @@ -4,9 +4,9 @@ use tracing_subscriber::prelude::*; /// Initialize tracing with the default configuration. pub fn initialize_tracing() { - // Always try to use journald subscriber if we're running under systemd + // Always try to use journald subscriber if we're running as root; // This ensures key messages (info, warn, error) go to the journal - let journald_layer = if let Ok(()) = std::env::var("JOURNAL_STREAM").map(|_| ()) { + let journald_layer = if rustix::process::getuid().is_root() { tracing_journald::layer() .ok() .map(|layer| layer.with_filter(tracing_subscriber::filter::LevelFilter::INFO))