pub struct LogEntry {
pub timestamp: SystemTime,
pub level: LogLevel,
pub message: String,
pub labels: HashMap<String, String>,
pub trace_id: Option<String>,
pub span_id: Option<String>,
pub source: Option<String>,
}Expand description
Structured log entry.
Fields§
§timestamp: SystemTimeTimestamp of the log entry.
level: LogLevelLog severity level.
message: StringLog message.
labels: HashMap<String, String>Optional labels/tags for the log entry.
trace_id: Option<String>Optional trace context (for correlation).
span_id: Option<String>Optional span context (for correlation).
source: Option<String>Source location (file, line).
Implementations§
Source§impl LogEntry
impl LogEntry
Sourcepub fn new(level: LogLevel, message: impl Into<String>) -> LogEntry
pub fn new(level: LogLevel, message: impl Into<String>) -> LogEntry
Creates a new log entry with the given level and message.
Sourcepub fn with_label(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> LogEntry
pub fn with_label( self, key: impl Into<String>, value: impl Into<String>, ) -> LogEntry
Adds a label to the log entry.
Sourcepub fn with_trace_id(self, trace_id: impl Into<String>) -> LogEntry
pub fn with_trace_id(self, trace_id: impl Into<String>) -> LogEntry
Sets the trace ID for correlation.
Sourcepub fn with_span_id(self, span_id: impl Into<String>) -> LogEntry
pub fn with_span_id(self, span_id: impl Into<String>) -> LogEntry
Sets the span ID for correlation.
Trait Implementations§
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