Skip to main content

tracing_systemd/
lib.rs

1//! A [`tracing_subscriber::Layer`] that pretty-prints span chains to stdout
2//! and (optionally) the systemd journal.
3//!
4//! # Quick start
5//!
6//! ```no_run
7//! use tracing::info;
8//! use tracing_subscriber::prelude::*;
9//! use tracing_systemd::SystemdLayer;
10//!
11//! tracing_subscriber::registry()
12//!     .with(SystemdLayer::stdout().with_target(true).with_thread_ids(true))
13//!     .init();
14//!
15//! info!("hello");
16//! ```
17//!
18//! # Features
19//!
20//! | Feature    | Default | Effect                                                                  |
21//! |------------|---------|-------------------------------------------------------------------------|
22//! | `colors`   | yes     | Enables ANSI color output via [`nu-ansi-term`](https://docs.rs/nu-ansi-term). |
23//! | `journald` | no      | Re-exports the official [`tracing-journald`](https://docs.rs/tracing-journald) layer through [`mod@journald`]. Pure-Rust; no `libsystemd-dev` build dependency. |
24//! | `json`     | no      | Adds [`SystemdLayer::json`] for one JSON object per event (uses [`serde_json`](https://docs.rs/serde_json)). |
25//!
26//! # Migrating from 0.1
27//!
28//! See [the README](https://github.com/ziidonato/tracing-systemd/blob/main/README.md#migration-from-01)
29//! for a method-by-method mapping.
30
31#![deny(missing_docs)]
32#![forbid(unsafe_code)]
33#![warn(
34    clippy::pedantic,
35    clippy::all,
36    rust_2018_idioms,
37    missing_debug_implementations
38)]
39#![cfg_attr(docsrs, feature(doc_cfg))]
40
41mod format;
42mod layer;
43mod output;
44mod visit;
45
46#[cfg(all(unix, feature = "journald"))]
47#[cfg_attr(docsrs, doc(cfg(all(unix, feature = "journald"))))]
48pub mod journald;
49
50pub use format::TimestampFormat;
51pub use layer::SystemdLayer;
52pub use output::Output;
53
54#[cfg(feature = "colors")]
55#[cfg_attr(docsrs, doc(cfg(feature = "colors")))]
56pub use format::{ColorMode, ColorTheme};