Files
heartwood/crates/radicle-systemd/src/journal.rs
T
Lorenz Leutgeb 8bac24d6ab rust/edition/fmt: 2021 → 2024
Reformat code with `rustfmt`, now that the edition changed from
Rust 2021 to Rust 2024.
2026-03-30 16:57:51 +02:00

21 lines
568 B
Rust

use systemd_journal_logger::{JournalLog, connected_to_journal};
/// If the current process is directly connected to the systemd journal,
/// return a logger that will write to it.
pub fn logger<K, V, I>(identifier: String, extra_fields: I) -> std::io::Result<Box<dyn log::Log>>
where
I: IntoIterator<Item = (K, V)>,
K: AsRef<str>,
V: AsRef<[u8]>,
{
Ok(Box::new(
JournalLog::new()?
.with_syslog_identifier(identifier)
.with_extra_fields(extra_fields),
))
}
pub fn connected() -> bool {
connected_to_journal()
}