mirror of
https://github.com/containers/bootc.git
synced 2026-02-05 06:45:13 +01:00
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 <walters@verbum.org>
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user