pub struct LogRecords(/* private fields */);Expand description
A set of records that can be attached to a logging scope.
LogRecords represents a set of key-value pairs that can be
added to log messages when the log context scope is active.
§Ordering
The order in which records appear is not guaranteed. Do not rely on any specific ordering of keys.
Implementations§
Source§impl LogRecords
impl LogRecords
pub fn new() -> Self
Sourcepub fn field(
self,
key: impl Into<Cow<'static, str>>,
value: impl Into<LogValue>,
) -> Self
pub fn field( self, key: impl Into<Cow<'static, str>>, value: impl Into<LogValue>, ) -> Self
Adds a key-value record to this collection, returning the collection for chained calls.
§Examples
This method takes ownership of self, so it can be used as part of a
builder-style chain:
use context_logger::LogRecords;
let records = LogRecords::new()
.field("user_id", "user-123")
.field("request_id", 42);Sourcepub fn insert(
&mut self,
key: impl Into<Cow<'static, str>>,
value: impl Into<LogValue>,
)
pub fn insert( &mut self, key: impl Into<Cow<'static, str>>, value: impl Into<LogValue>, )
Adds a key-value record to this collection.
Sourcepub fn extend(
&mut self,
other: impl IntoIterator<Item = (Cow<'static, str>, LogValue)>,
)
pub fn extend( &mut self, other: impl IntoIterator<Item = (Cow<'static, str>, LogValue)>, )
Extends this collection with the records from another collection.
Trait Implementations§
Source§impl Clone for LogRecords
impl Clone for LogRecords
Source§fn clone(&self) -> LogRecords
fn clone(&self) -> LogRecords
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LogRecords
impl Debug for LogRecords
Source§impl Default for LogRecords
impl Default for LogRecords
Source§fn default() -> LogRecords
fn default() -> LogRecords
Returns the “default value” for a type. Read more
Source§impl<'a> IntoIterator for &'a LogRecords
impl<'a> IntoIterator for &'a LogRecords
Source§impl IntoIterator for LogRecords
impl IntoIterator for LogRecords
Auto Trait Implementations§
impl !RefUnwindSafe for LogRecords
impl !UnwindSafe for LogRecords
impl Freeze for LogRecords
impl Send for LogRecords
impl Sync for LogRecords
impl Unpin for LogRecords
impl UnsafeUnpin for LogRecords
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