Skip to content

Commit

Permalink
logger: Allow journald output to be disabled at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Jan 17, 2025
1 parent 3836670 commit f893622
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/logger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ pub fn init_logger() -> Result<()> {

let fmt_layer = fmt::layer().compact();

match journald::layer() {
Ok(journald_layer) => tracing_subscriber::registry()
match (!crate::utils::env::bool_var("COSMIC_DISABLE_JOURNALD").unwrap_or(false))
.then(|| journald::layer())
{
Some(Ok(journald_layer)) => tracing_subscriber::registry()
.with(fmt_layer)
.with(journald_layer)
.with(filter)
.init(),
Err(err) => {
x @ None | x @ Some(Err(_)) => {
tracing_subscriber::registry()
.with(fmt_layer)
.with(filter)
.init();
warn!(?err, "Failed to init journald logging.");
if let Some(Err(err)) = x {
warn!(?err, "Failed to init journald logging.");
}
}
};
log_panics::init();
Expand Down

0 comments on commit f893622

Please sign in to comment.