Skip to content

Commit 8768d70

Browse files
committed
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 <[email protected]>
1 parent bbc4be3 commit 8768d70

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/utils/src/tracing_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use tracing_subscriber::prelude::*;
44

55
/// Initialize tracing with the default configuration.
66
pub fn initialize_tracing() {
7-
// Always try to use journald subscriber if we're running under systemd
7+
// Always try to use journald subscriber if we're running as root;
88
// This ensures key messages (info, warn, error) go to the journal
9-
let journald_layer = if let Ok(()) = std::env::var("JOURNAL_STREAM").map(|_| ()) {
9+
let journald_layer = if rustix::process::getuid().is_root() {
1010
tracing_journald::layer()
1111
.ok()
1212
.map(|layer| layer.with_filter(tracing_subscriber::filter::LevelFilter::INFO))

0 commit comments

Comments
 (0)