Skip to main content

zerodds_security_logging/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3
4//! Crate `zerodds-security-logging`. Safety classification: **SAFE** (a pure I/O wrapper; no secrets are buffered outside the log line itself).
5//!
6//! Production-grade logging backends for DDS-Security 1.1/1.2 §8.6
7//! (the `LoggingPlugin` SPI from `zerodds-security`).
8//!
9//! ## Layer position
10//!
11//! Layer 4 — Core Services. Consumed by end-user builds + the DCPS runtime
12//! (feature `security`).
13//!
14//! ## Public API (as of 1.0.0-rc.1)
15//!
16//! - [`StderrLoggingPlugin`] — structured log lines to `stderr`.
17//! - [`JsonLinesLoggingPlugin`] — `application/x-ndjson` to a file.
18//! - [`SyslogLoggingPlugin`] — RFC-5424 UDP backend (facility `LOCAL0`).
19//! - [`FanOutLoggingPlugin`] — fan-out to multiple backends.
20//!
21//! # What this crate provides
22//!
23//! 1. [`StderrLoggingPlugin`] — writes structured log lines to
24//!    `stderr`. Default for development + container deployments with a
25//!    stdout/stderr collector (Loki, Vector, Fluentd).
26//! 2. [`JsonLinesLoggingPlugin`] — writes JSON lines
27//!    (`application/x-ndjson`) to a file. Each line = one event.
28//!    A second process (e.g. auditd, filebeat) rotates the file.
29//! 3. [`FanOutLoggingPlugin`] — routes each event to **multiple**
30//!    backends (e.g. stderr + JSON file simultaneously).
31//!
32//! All backends filter events by `LogLevel`; the default level is
33//! `Warning` — lower (Informational, Debug) is silently discarded.
34//!
35//! ## Non-goals
36//!
37//! - Syslog TCP (RFC 5425) and syslog TLS — most syslog
38//!   deployments run in a trusted segment; re-add on demand.
39//! - Structured telemetry (OpenTelemetry / OTLP) — covered by
40//!   `zerodds-observability-otlp` (layer 4.6).
41//! - Log rotation in the plugin itself — the job of the operating system /
42//!   `logrotate`.
43
44#![cfg_attr(not(feature = "std"), no_std)]
45#![forbid(unsafe_code)]
46#![warn(missing_docs)]
47// Three plugin impls for box polymorphism — SPI-driven.
48// zerodds-lint: allow no_dyn_in_safe
49
50extern crate alloc;
51
52mod fanout;
53#[cfg(feature = "std")]
54mod from_properties;
55mod jsonl;
56mod stderr_sink;
57mod syslog;
58
59pub use fanout::FanOutLoggingPlugin;
60#[cfg(feature = "std")]
61pub use from_properties::{
62    LogConfigError, PROP_LOG_JSONL_PATH, PROP_LOG_LEVEL, PROP_LOG_PLUGIN, PROP_LOG_SYSLOG_ADDR,
63    PROP_LOG_SYSLOG_APP, PROP_LOG_SYSLOG_HOST, logging_plugin_from_properties, parse_log_level,
64};
65pub use jsonl::JsonLinesLoggingPlugin;
66pub use stderr_sink::StderrLoggingPlugin;
67pub use syslog::SyslogLoggingPlugin;