pub struct StructuredLogEvent {
pub timestamp: u64,
pub level: LogLevel,
pub target: String,
pub message: String,
pub fields: Vec<(String, String)>,
pub span_id: Option<String>,
pub trace_id: Option<String>,
pub connection_id: Option<String>,
}
Expand description
Structured log event with full metadata
Fields§
§timestamp: u64
Timestamp in microseconds since epoch
level: LogLevel
Log severity level
target: String
Logical target of the log (module or subsystem)
message: String
Human-readable message
fields: Vec<(String, String)>
Structured key/value fields attached to the record
span_id: Option<String>
Optional span identifier
trace_id: Option<String>
Optional trace identifier
connection_id: Option<String>
Optional connection identifier
Implementations§
Source§impl StructuredLogEvent
impl StructuredLogEvent
Sourcepub fn new(
level: Level,
target: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn new( level: Level, target: impl Into<String>, message: impl Into<String>, ) -> Self
Create a new structured log event
Sourcepub fn with_field(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_field( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a field to the event
Sourcepub fn with_fields(self, fields: Vec<(String, String)>) -> Self
pub fn with_fields(self, fields: Vec<(String, String)>) -> Self
Add multiple fields
Sourcepub fn with_span_id(self, span_id: impl Into<String>) -> Self
pub fn with_span_id(self, span_id: impl Into<String>) -> Self
Set the span ID
Sourcepub fn with_trace_id(self, trace_id: impl Into<String>) -> Self
pub fn with_trace_id(self, trace_id: impl Into<String>) -> Self
Set the trace ID
Sourcepub fn with_connection_id(self, conn_id: &ConnectionId) -> Self
pub fn with_connection_id(self, conn_id: &ConnectionId) -> Self
Set the connection ID
Sourcepub fn to_json_pretty(&self) -> Result<String, Error>
pub fn to_json_pretty(&self) -> Result<String, Error>
Convert to pretty JSON
Trait Implementations§
Source§impl Clone for StructuredLogEvent
impl Clone for StructuredLogEvent
Source§fn clone(&self) -> StructuredLogEvent
fn clone(&self) -> StructuredLogEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for StructuredLogEvent
impl Debug for StructuredLogEvent
Source§impl<'de> Deserialize<'de> for StructuredLogEvent
impl<'de> Deserialize<'de> for StructuredLogEvent
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 StructuredLogEvent
impl RefUnwindSafe for StructuredLogEvent
impl Send for StructuredLogEvent
impl Sync for StructuredLogEvent
impl Unpin for StructuredLogEvent
impl UnwindSafe for StructuredLogEvent
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