From d47754d41e915bb5e5a698970beb93a9a04eaa88 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 17 Jan 2025 18:18:26 +0100 Subject: [PATCH] logger: Don't log to stdout/err, if cosmic-session started us --- src/logger/mod.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/logger/mod.rs b/src/logger/mod.rs index 1f003ccf..c18218cd 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -30,11 +30,20 @@ pub fn init_logger() -> Result<()> { let fmt_layer = fmt::layer().compact(); match journald::layer() { - Ok(journald_layer) => tracing_subscriber::registry() - .with(fmt_layer) - .with(journald_layer) - .with(filter) - .init(), + Ok(journald_layer) => { + if std::env::var_os("COSMIC_SESSION_SOCK").is_some() { + tracing_subscriber::registry() + .with(journald_layer) + .with(filter) + .init() + } else { + tracing_subscriber::registry() + .with(fmt_layer) + .with(journald_layer) + .with(filter) + .init() + } + } Err(err) => { tracing_subscriber::registry() .with(fmt_layer)