pub struct LogEntry { /* private fields */ }Expand description
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
Creates a new log entry with the given level and message.
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
Adds a structured field to the entry.
Fields are key-value pairs that provide context. If the maximum number of fields is reached, additional fields are ignored.
Sourcepub fn with_timestamp(self, timestamp: Time) -> Self
pub fn with_timestamp(self, timestamp: Time) -> Self
Sets the timestamp for the entry.
Sourcepub fn with_target(self, target: impl Into<String>) -> Self
pub fn with_target(self, target: impl Into<String>) -> Self
Sets the target/module name for the entry.
Sourcepub fn with_context(self, ctx: &DiagnosticContext) -> Self
pub fn with_context(self, ctx: &DiagnosticContext) -> Self
Adds diagnostic context fields to the entry.
Sourcepub fn fields(&self) -> impl Iterator<Item = (&str, &str)>
pub fn fields(&self) -> impl Iterator<Item = (&str, &str)>
Returns an iterator over the fields.
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Returns the number of fields.
Sourcepub fn format_compact(&self) -> String
pub fn format_compact(&self) -> String
Formats the entry as a single-line string (for compact output).
Sourcepub fn format_json(&self) -> String
pub fn format_json(&self) -> String
Formats the entry as JSON (for structured logging pipelines).
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
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: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).