1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Optional journald layer: a thin convenience wrapper around the official
//! [`tracing-journald`](https://docs.rs/tracing-journald) crate.
//!
//! `tracing-journald` speaks the systemd journal native socket protocol in
//! pure Rust, so enabling this feature does **not** add a build-time
//! dependency on `libsystemd-dev`.
use io;
/// Build the official [`tracing_journald::Layer`] with default settings.
///
/// Returns `Err` if the journal socket cannot be opened (typically
/// `/run/systemd/journal/socket`), e.g. when running outside of systemd.
///
/// # Composition
///
/// ```no_run
/// use tracing_subscriber::prelude::*;
/// use tracing_systemd::SystemdLayer;
///
/// let journald = tracing_systemd::journald::layer().ok();
/// tracing_subscriber::registry()
/// .with(SystemdLayer::stdout())
/// .with(journald)
/// .init();
/// ```
///
/// `Option<Layer>` implements `Layer<S>`, so passing `None` cleanly disables
/// the journald layer when journald isn't available.
///
/// # Errors
///
/// Returns the underlying [`io::Error`] from [`tracing_journald::layer`]
/// when the journal socket can't be opened.
/// Build a [`tracing_journald::Layer`] with a specific
/// `SYSLOG_IDENTIFIER` (filterable via `journalctl -t <identifier>`).
///
/// # Errors
///
/// Returns the underlying [`io::Error`] from [`tracing_journald::layer`]
/// when the journal socket can't be opened.