pub struct LogEvent {Show 14 fields
pub timestamp_ms: u64,
pub severity: Severity,
pub verbosity: Verbosity,
pub message: String,
pub component: String,
pub module: Option<String>,
pub operation: Option<String>,
pub sensitivity: Sensitivity,
pub application_id: Option<String>,
pub node_id: Option<String>,
pub tenant_id: Option<String>,
pub trace_id: Option<String>,
pub request_id: Option<String>,
pub fields: Vec<LogField>,
}Expand description
Structured operational event passed through the sanitizer before normal sinks.
Fields§
§timestamp_ms: u64Unix timestamp in milliseconds supplied by the caller or clock boundary.
severity: SeverityOperational impact.
verbosity: VerbosityDetail threshold independent from severity.
message: StringHuman-readable message.
component: StringStable subsystem name used for policy overrides.
module: Option<String>Optional source module when the caller has a stable module name.
operation: Option<String>Optional named operation being observed.
sensitivity: SensitivityRequested handling class; a policy can only preserve or reduce detail.
application_id: Option<String>Optional application identity.
node_id: Option<String>Optional node identity.
tenant_id: Option<String>Optional tenant identity.
trace_id: Option<String>Optional trace correlation identifier.
request_id: Option<String>Optional request correlation identifier.
fields: Vec<LogField>Extra bounded structured values.
Implementations§
Source§impl LogEvent
impl LogEvent
Sourcepub fn new(
timestamp_ms: u64,
severity: Severity,
verbosity: Verbosity,
component: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn new( timestamp_ms: u64, severity: Severity, verbosity: Verbosity, component: impl Into<String>, message: impl Into<String>, ) -> Self
Creates a normal operational event without allocating optional metadata.
Examples found in repository?
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}Sourcepub fn field(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn field(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds one structured field.
Sourcepub fn path(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn path(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds one path field which is alias-sanitized by normal policies.
Examples found in repository?
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}Sourcepub fn secret(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn secret(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds one secret field which ordinary policies redact before dispatch.
Sourcepub fn module(self, module: impl Into<String>) -> Self
pub fn module(self, module: impl Into<String>) -> Self
Adds the stable source module without inferring it from compiler state.
Sourcepub fn operation(self, operation: impl Into<String>) -> Self
pub fn operation(self, operation: impl Into<String>) -> Self
Adds a bounded caller-defined operation name.
Sourcepub fn sensitivity(self, sensitivity: Sensitivity) -> Self
pub fn sensitivity(self, sensitivity: Sensitivity) -> Self
Requests a handling class; sensitive delivery still requires a policy.
Sourcepub fn validate(&self) -> Result<(), LogEventError>
pub fn validate(&self) -> Result<(), LogEventError>
Validates bounded event storage before sanitization and sink I/O.
Sourcepub fn retained_bytes(&self) -> usize
pub fn retained_bytes(&self) -> usize
Estimates retained heap bytes without serializing or allocating.