Journal support

This commit is contained in:
mdecimus 2023-09-15 19:39:03 +02:00
parent 0a640c3758
commit 216fcf2d73
4 changed files with 25 additions and 1 deletions

12
Cargo.lock generated
View file

@ -5484,6 +5484,17 @@ dependencies = [
"valuable",
]
[[package]]
name = "tracing-journald"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba316a74e8fc3c3896a850dba2375928a9fa171b085ecddfc7c054d39970f3fd"
dependencies = [
"libc",
"tracing-core",
"tracing-subscriber",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
@ -5775,6 +5786,7 @@ dependencies = [
"tokio-rustls",
"tracing",
"tracing-appender",
"tracing-journald",
"tracing-opentelemetry",
"tracing-subscriber",
]

View file

@ -363,7 +363,7 @@ impl SMTP {
assert_eq!(value, expected, "Variable {name:?} has unexpected value");
} else {
panic!("Missing variable {name:?} with value {expected:?}\nExpected {:?}\nFound: {:?}",
expected_variables.keys().collect::<Vec<_>>(),
expected_variables.keys().collect::<Vec<_>>(),
instance.global_variable_names().collect::<Vec<_>>());
}
}

View file

@ -25,6 +25,7 @@ ahash = { version = "0.8" }
[target.'cfg(unix)'.dependencies]
privdrop = "0.5.3"
tracing-journald = "0.3"
[features]
test_mode = []

View file

@ -179,6 +179,17 @@ pub fn enable_tracing(config: &Config, message: &str) -> config::Result<Option<W
Ok(None)
}
#[cfg(unix)]
"journal" => {
tracing::subscriber::set_global_default(
tracing_subscriber::Registry::default()
.with(tracing_journald::layer().failed("Failed to configure journal"))
.with(env_filter),
)
.failed("Failed to set subscriber");
Ok(None)
}
_ => Ok(None),
};