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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! `tracing-subscriber` layer for logging to the systemd journal
//!
//! Provides a [`SystemdLayer`] implementation for use with `tracing-subscriber` that can be configured.
//! Shows all spans and arguments.
//!
//! # Features
//! - `colored` (default): Enables colored output
//! - `sd-journal`: Enables logging to the systemd journal (useful for running outside of a service)
//! - Requires `libsystemd-dev` to be installed
//! - Filter using `-t` | `--identifier` (e.g. `journalctl -t <identifier>`)
//!
//! # Example
//! ```rust
//! use tracing::error;
//!
//! use tracing::{debug, info, instrument, trace, warn};
//! use tracing_subscriber::prelude::*;
//! use tracing_systemd::SystemdLayer;
//! fn main() {
//! tracing_subscriber::registry()
//! .with(
//! SystemdLayer::new()
//! .with_target(true)
//! .use_level_prefix(false)
//! .use_color(true)
//! .with_thread_ids(true),
//! )
//! .init();
//!
//! root_log_fn(true);
//! }
//!
//! #[instrument(fields(outside_instrument_field = true))]
//! fn root_log_fn(outside_instrument_field: bool) {
//! info!("Root log");
//! inner_log_1(true);
//! }
//!
//! #[instrument(fields(inside_instrument_field = true))]
//! fn inner_log_1(inside_parameter_field: bool) {
//! trace!("this is a trace");
//! debug!(field_in_function = "also works");
//! info!("this is an info log");
//! warn!("Inner log 1");
//! error!("this is an error");
//! }
//! ```
pub use SystemdLayer;