pub struct LogEntry {
pub timestamp: DateTime<Utc>,
pub level: LogLevel,
pub source_pid: Option<Pid>,
pub source_service: Option<String>,
pub message: String,
pub fields: HashMap<String, Value>,
pub trace_id: Option<String>,
}Expand description
A structured log entry.
Fields§
§timestamp: DateTime<Utc>When the log entry was created.
level: LogLevelLog severity level.
source_pid: Option<Pid>PID of the source agent (if applicable).
source_service: Option<String>Name of the source service (if applicable).
message: StringHuman-readable log message.
fields: HashMap<String, Value>Structured fields (key-value metadata).
trace_id: Option<String>Distributed trace ID for correlated log queries.
Implementations§
Source§impl LogEntry
impl LogEntry
Sourcepub fn new(level: LogLevel, message: impl Into<String>) -> Self
pub fn new(level: LogLevel, message: impl Into<String>) -> Self
Create a new log entry with minimal fields.
Sourcepub fn with_service(self, service: impl Into<String>) -> Self
pub fn with_service(self, service: impl Into<String>) -> Self
Set the source service name.
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_field(self, key: impl Into<String>, value: Value) -> Self
pub fn with_field(self, key: impl Into<String>, value: Value) -> Self
Add a structured field.
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 UnsafeUnpin 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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