Expand description
Reusable diagnostic logging and telemetry substrate for JSONL diagnostics. Reusable diagnostic logging and telemetry substrate.
This module provides the shared infrastructure for JSONL diagnostic
logging and telemetry hooks, extracted from the common patterns in
crate::inspector and the demo showcase’s mouse_playground.
§Design
The core types are generic over the entry type, so each consumer
defines its own DiagnosticEntry / DiagnosticEventKind while
reusing the log, dispatch, and checksum infrastructure.
§Key Types
- [
DiagnosticRecord] — trait for entries that can be serialized to JSONL DiagnosticLog— bounded in-memory log with optional stderr mirroringTelemetryCallback— type alias for observer callbacks- [
fnv1a_hash] — FNV-1a checksum utility for determinism verification
§Example
ⓘ
use ftui_widgets::diagnostics::{DiagnosticLog, DiagnosticRecord};
#[derive(Debug, Clone)]
struct MyEntry { kind: &'static str, data: u64 }
impl DiagnosticRecord for MyEntry {
fn to_jsonl(&self) -> String {
format!("{{\"kind\":\"{}\",\"data\":{}}}", self.kind, self.data)
}
}
let mut log = DiagnosticLog::<MyEntry>::new();
log.record(MyEntry { kind: "test", data: 42 });
assert_eq!(log.entries().len(), 1);Structs§
- Diagnostic
Log - Bounded in-memory diagnostic log with optional stderr mirroring.
- Diagnostic
Support - Shared state for optional diagnostic logging plus optional telemetry hooks.
Traits§
- Diagnostic
Hook Dispatch - Trait implemented by telemetry hook collections that can observe
diagnostic entries of type
E. - Diagnostic
Record - Trait for diagnostic entries that can be serialized to JSONL.
Functions§
- env_
flag_ enabled - Check an environment variable as a boolean diagnostic flag.
- fnv1a_
hash - Compute an FNV-1a 64-bit hash of the given byte slice.
- json_
string_ literal - Encode a string as a JSON string literal.
Type Aliases§
- Telemetry
Callback - Callback type for telemetry hooks.