pub struct LogEntry {
pub timestamp: DateTime<Utc>,
pub level: SecurityLevel,
pub message: String,
pub metadata: Option<Value>,
pub integrity_hash: String,
pub source: Option<String>,
pub category: Option<String>,
}Expand description
A single log entry with cryptographic integrity protection
Fields§
§timestamp: DateTime<Utc>UTC timestamp when entry was created
level: SecurityLevelSecurity level
message: StringLog message
metadata: Option<Value>Optional structured data (user ID, transaction ID, etc.)
integrity_hash: StringSHA-256 hash of entry content for tamper detection
source: Option<String>Optional source identifier (hostname, service name)
category: Option<String>Optional category for filtering
Implementations§
Source§impl LogEntry
impl LogEntry
Sourcepub fn new(
level: SecurityLevel,
message: String,
metadata: Option<Value>,
) -> Self
pub fn new( level: SecurityLevel, message: String, metadata: Option<Value>, ) -> Self
Create a new log entry with integrity hash
Sourcepub fn new_with_context(
level: SecurityLevel,
message: String,
metadata: Option<Value>,
source: Option<String>,
category: Option<String>,
) -> Self
pub fn new_with_context( level: SecurityLevel, message: String, metadata: Option<Value>, source: Option<String>, category: Option<String>, ) -> Self
Create a new log entry with source and category
Sourcepub fn verify_integrity(&self) -> bool
pub fn verify_integrity(&self) -> bool
Verify entry integrity (detect tampering)
Sourcepub fn to_json_pretty(&self) -> Result<String, Error>
pub fn to_json_pretty(&self) -> Result<String, Error>
Serialize to pretty JSON
Sourcepub fn to_log_line(&self) -> String
pub fn to_log_line(&self) -> String
Get formatted log line for file output
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LogEntry
impl<'de> Deserialize<'de> for LogEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LogEntry
impl RefUnwindSafe for LogEntry
impl Send for LogEntry
impl Sync for LogEntry
impl Unpin for LogEntry
impl UnwindSafe for LogEntry
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