pub struct SensitiveDntSink<P: DntKeyProvider> { /* private fields */ }Expand description
Encrypted DNT sink. It has no plaintext fallback and must be explicitly wired.
Implementations§
Source§impl<P: DntKeyProvider> SensitiveDntSink<P>
impl<P: DntKeyProvider> SensitiveDntSink<P>
Sourcepub fn new(
config: SensitiveDntSinkConfig,
key_provider: P,
) -> Result<Self, LogError>
pub fn new( config: SensitiveDntSinkConfig, key_provider: P, ) -> Result<Self, LogError>
Creates the sink; enabling it is an explicit sensitive-logging decision.
Examples found in repository?
examples/sensitive_diagnostics.rs (lines 31-42)
24fn main() -> Result<(), appcore_log::LogError> {
25 let key_id = KeyId::new("example-log-key").map_err(|_| appcore_log::LogError::Encryption)?;
26
27 let provider =
28 StaticDntKeyProvider::new().with_key(key_id.clone(), SecretKey::new(demo_key()?));
29
30 // The sink bounds the encrypted snapshot by both bytes and event count.
31 let sink = SensitiveDntSink::new(
32 SensitiveDntSinkConfig {
33 path: std::env::temp_dir().join("appcore-sensitive-log.dnt"),
34 application_id: ApplicationId::new("example-log")
35 .map_err(|_| appcore_log::LogError::Encryption)?,
36 key_id,
37 max_bytes: 4096,
38 max_events: 8,
39 retention: 2,
40 },
41 provider,
42 )?;
43
44 // Sensitive mode must be explicit and has no console or JSONL fallback.
45 let mut policy = LogPolicy::default();
46 policy.sensitivity = Sensitivity::Sensitive;
47
48 let log = LogDispatcher::new(policy, vec![Arc::new(sink)]);
49
50 log.event(0, "security").verbosity(2).error("diagnostic");
51
52 Ok(())
53}Trait Implementations§
Auto Trait Implementations§
impl<P> !Freeze for SensitiveDntSink<P>
impl<P> !RefUnwindSafe for SensitiveDntSink<P>
impl<P> Send for SensitiveDntSink<P>
impl<P> Sync for SensitiveDntSink<P>
impl<P> Unpin for SensitiveDntSink<P>where
P: Unpin,
impl<P> UnsafeUnpin for SensitiveDntSink<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for SensitiveDntSink<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more