pub struct FieldEncoder<'a> { /* private fields */ }Expand description
Encoder for adding key-value fields and span information to a log entry.
Created by Encoder::append or FieldBuffer::encoder. When dropped,
the log entry is finalized with the correct length header.
Implementations§
Source§impl<'a> FieldEncoder<'a>
impl<'a> FieldEncoder<'a>
Sourcepub fn fields(self) -> LogFields<'a> ⓘ
pub fn fields(self) -> LogFields<'a> ⓘ
Converts this encoder into an iterator over the encoded fields.
Consumes the encoder without finalizing the log entry header.
Sourcepub fn start_span(self, span: SpanID)
pub fn start_span(self, span: SpanID)
Encodes a span start marker for the given span ID.
Consumes the encoder to finalize the log entry.
Sourcepub fn start_span_with_parent(self, span: SpanID, parent: Option<SpanID>)
pub fn start_span_with_parent(self, span: SpanID, parent: Option<SpanID>)
Encodes a span start marker with an optional parent span.
Consumes the encoder to finalize the log entry.
Sourcepub fn apply_span(self, span: SpanID)
pub fn apply_span(self, span: SpanID)
Associates this log entry with an active span.
Consumes the encoder to finalize the log entry.
Sourcepub fn end_span(self, span: SpanID)
pub fn end_span(self, span: SpanID)
Encodes a span end marker for the given span ID.
Consumes the encoder to finalize the log entry.
Sourcepub fn apply_span_info(self, info: SpanInfo)
pub fn apply_span_info(self, info: SpanInfo)
Applies the given span information to this log entry.
Consumes the encoder to finalize the log entry.
Sourcepub fn apply_current_span(self)
pub fn apply_current_span(self)
Associates this log entry with the current thread-local span, if any.
Consumes the encoder to finalize the log entry.
Sourcepub fn key(&mut self, key: &str) -> ValueEncoder<'_>
pub fn key(&mut self, key: &str) -> ValueEncoder<'_>
Begins encoding a field with the given key name.
If the key matches a known static key, uses the compact single-byte encoding.
Returns a ValueEncoder for encoding the field value.
§Panics
Panics if the key exceeds 127 bytes.
Sourcepub fn dynamic_key(&mut self, key: &str) -> ValueEncoder<'_>
pub fn dynamic_key(&mut self, key: &str) -> ValueEncoder<'_>
Sourcepub fn static_key(&mut self, key: StaticKey) -> ValueEncoder<'_>
pub fn static_key(&mut self, key: StaticKey) -> ValueEncoder<'_>
Begins encoding a field with a known static key.
Uses the compact single-byte encoding for the key.