trace2e_core/lib.rs
1//! A distributed traceability middleware.
2//!
3//! This software provides a mediation layer that provides provenance recording
4//! and compliance enforcement on I/O objects such as files or streams. The use
5//! of a custom I/O library is required to wrap standard I/O library methods to
6//! make input/output conditional on middleware authorization.
7//!
8//! A unique instance of this software should run on each node where
9//! traceability is enforced.
10//!
11//! Process/middleware and middleware/middleware communication relies on [`tonic`],
12//! a Rust implementation of gRPC, a high performance, open source RPC framework.
13//!
14//! [`tonic`]: https://docs.rs/tonic
15
16#[cfg(test)]
17pub mod tests;
18
19pub mod traceability;
20pub mod transport;
21
22#[cfg(feature = "trace2e_tracing")]
23pub mod trace2e_tracing {
24 use std::sync::Once;
25
26 use tracing_subscriber::{EnvFilter, fmt};
27
28 static INIT: Once = Once::new();
29
30 /// Initialize tracing for tests
31 /// This sets up a tracing subscriber that will display logs during test execution.
32 /// Call this at the beginning of tests that need to see tracing output.
33 pub fn init() {
34 INIT.call_once(|| {
35 let filter =
36 EnvFilter::try_from_default_env().or_else(|_| EnvFilter::try_new("off")).unwrap();
37
38 fmt().with_target(false).with_test_writer().with_env_filter(filter).init();
39 });
40 }
41}