pub struct LogEntry {
pub level: LogLevel,
pub message: String,
pub target: Option<String>,
pub fields: HashMap<String, Value>,
pub timestamp: DateTime<Utc>,
pub trace_id: Option<String>,
pub span_id: Option<String>,
pub node_id: Option<Uuid>,
}Expand description
A structured log entry.
Fields§
§level: LogLevelLog level.
message: StringLog message.
target: Option<String>Target (module path).
fields: HashMap<String, Value>Structured fields.
timestamp: DateTime<Utc>Timestamp.
trace_id: Option<String>Trace ID if part of a trace.
span_id: Option<String>Span ID if part of a span.
node_id: Option<Uuid>Node ID that generated this log.
Implementations§
Source§impl LogEntry
impl LogEntry
Sourcepub fn with_target(self, target: impl Into<String>) -> Self
pub fn with_target(self, target: impl Into<String>) -> Self
Set the target.
Sourcepub fn with_field(self, key: impl Into<String>, value: impl Serialize) -> Self
pub fn with_field(self, key: impl Into<String>, value: impl Serialize) -> Self
Add a field.
Sourcepub fn with_fields(self, fields: HashMap<String, Value>) -> Self
pub fn with_fields(self, fields: HashMap<String, Value>) -> Self
Add multiple fields.
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_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_node_id(self, node_id: Uuid) -> Self
pub fn with_node_id(self, node_id: Uuid) -> Self
Set the node ID.
Sourcepub fn matches_level(&self, min_level: LogLevel) -> bool
pub fn matches_level(&self, min_level: LogLevel) -> bool
Check if this log matches a minimum level filter.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more