Skip to main content

safe_paths/
safe_paths.rs

1// =============================================================================
2//        #######
3//     ###       ###     F: safe_paths.rs
4//    ##   ## ##   ##    P: AppCore-Runtime
5//         ## ##
6//                       C: unknown by dnettoRaw
7//    ##   ## ##   ##    U: working-tree by dnettoRaw
8//      ###########      S: 1.0.2-rc
9// =============================================================================
10
11//! Typed paths are alias-sanitized before ordinary sinks receive them.
12//!
13//! This example builds `LogEvent` directly because it demonstrates a typed path
14//! field. Free-form message text must not carry filesystem paths or secrets.
15
16use appcore_log::{LogEvent, LogPolicy, Severity, Verbosity};
17
18fn main() {
19    let mut policy = LogPolicy::default();
20
21    // The deployment provides trusted aliases instead of exposing host paths.
22    policy.paths.app_root = Some("/application".to_string());
23
24    let event = LogEvent::new(0, Severity::Info, Verbosity::V4, "storage", "opened")
25        .path("file", "/application/data/log.jsonl");
26
27    // Ordinary sinks receive `<APP_ROOT>/data/log.jsonl`, never the raw path.
28    let _safe = policy.sanitize(&event);
29}