Make failure to connect to journald a warning, not a hard error
This commit is contained in:
parent
6519f1d068
commit
65d4ee1fe2
1 changed files with 23 additions and 6 deletions
29
src/main.rs
29
src/main.rs
|
|
@ -44,17 +44,34 @@ async fn main() -> Result<()> {
|
||||||
color_eyre::install().wrap_err("failed to install color_eyre error handler")?;
|
color_eyre::install().wrap_err("failed to install color_eyre error handler")?;
|
||||||
|
|
||||||
let trace = tracing_subscriber::registry();
|
let trace = tracing_subscriber::registry();
|
||||||
|
let env_filter = EnvFilter::builder()
|
||||||
|
.with_default_directive(LevelFilter::INFO.into())
|
||||||
|
.from_env_lossy();
|
||||||
|
|
||||||
#[cfg(feature = "systemd")]
|
#[cfg(feature = "systemd")]
|
||||||
let trace = trace.with(tracing_journald::layer().wrap_err("failed to connect to journald")?);
|
if let Ok(journald) = tracing_journald::layer() {
|
||||||
|
trace
|
||||||
|
.with(journald)
|
||||||
|
.with(fmt::layer())
|
||||||
|
.with(env_filter)
|
||||||
|
.try_init()
|
||||||
|
.wrap_err("failed to initialize logger")?;
|
||||||
|
} else {
|
||||||
|
trace
|
||||||
|
.with(fmt::layer())
|
||||||
|
.with(env_filter)
|
||||||
|
.try_init()
|
||||||
|
.wrap_err("failed to initialize logger")?;
|
||||||
|
warn!("failed to connect to journald")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "systemd"))]
|
||||||
trace
|
trace
|
||||||
.with(fmt::layer())
|
.with(fmt::layer())
|
||||||
.with(
|
.with(env_filter)
|
||||||
EnvFilter::builder()
|
|
||||||
.with_default_directive(LevelFilter::INFO.into())
|
|
||||||
.from_env_lossy(),
|
|
||||||
)
|
|
||||||
.try_init()
|
.try_init()
|
||||||
.wrap_err("failed to initialize logger")?;
|
.wrap_err("failed to initialize logger")?;
|
||||||
|
|
||||||
log_panics::init();
|
log_panics::init();
|
||||||
|
|
||||||
let (session_tx, mut session_rx) = tokio::sync::mpsc::channel(10);
|
let (session_tx, mut session_rx) = tokio::sync::mpsc::channel(10);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue