pub struct Record<'a> {
pub metadata: Metadata<'a>,
pub message: &'a str,
pub fields: &'a [Field<'a>],
pub context: &'a [Field<'a>],
}Expand description
A complete, immutable log record.
Records borrow their data; the lifetime parameter is the shortest
of the borrows. A crate::Sink receives a &Record and must not
outlive it.
Fields§
§metadata: Metadata<'a>Static origin and severity information.
message: &'a strFree-form message.
fields: &'a [Field<'a>]Borrowed structured fields. May be empty.
context: &'a [Field<'a>]Borrowed context fields. May be empty. Distinct from fields
so formatters can label them (for example, prefixing context
keys in human format) and filters can skip them.
Implementations§
Source§impl<'a> Record<'a>
impl<'a> Record<'a>
Sourcepub const fn new(
metadata: Metadata<'a>,
message: &'a str,
fields: &'a [Field<'a>],
) -> Self
pub const fn new( metadata: Metadata<'a>, message: &'a str, fields: &'a [Field<'a>], ) -> Self
Build a record with no context fields.
Sourcepub const fn with_context(
metadata: Metadata<'a>,
message: &'a str,
fields: &'a [Field<'a>],
context: &'a [Field<'a>],
) -> Self
pub const fn with_context( metadata: Metadata<'a>, message: &'a str, fields: &'a [Field<'a>], context: &'a [Field<'a>], ) -> Self
Build a record with explicit context fields.
Sourcepub fn all_fields(&self) -> impl Iterator<Item = &Field<'a>>
pub fn all_fields(&self) -> impl Iterator<Item = &Field<'a>>
Iterate over context fields followed by structured fields.
Most formatters render them in this order so context appears before the per-call data.
Trait Implementations§
impl<'a> Copy for Record<'a>
Auto Trait Implementations§
impl<'a> Freeze for Record<'a>
impl<'a> RefUnwindSafe for Record<'a>
impl<'a> Send for Record<'a>
impl<'a> Sync for Record<'a>
impl<'a> Unpin for Record<'a>
impl<'a> UnsafeUnpin for Record<'a>
impl<'a> UnwindSafe for Record<'a>
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