pub struct LogContext { /* private fields */ }Expand description
A set of records that can be attached to a logging scope.
LogContext represents a set of key-value pairs that will be
automatically added to log messages when the context scope is active.
Implementations§
Source§impl LogContext
impl LogContext
Sourcepub fn with_record(
self,
key: impl Into<Cow<'static, str>>,
value: impl Into<LogValue>,
) -> Self
pub fn with_record( self, key: impl Into<Cow<'static, str>>, value: impl Into<LogValue>, ) -> Self
Adds a record to this context.
§Ordering
The order in which records appear in log output is not guaranteed. Do not rely on any specific ordering of keys.
§Examples
use context_logger::LogContext;
let context = LogContext::new()
.with_record("user_id", "user-123")
.with_record("request_id", 42)
.with_record("is_admin", true);Trait Implementations§
Source§impl Clone for LogContext
impl Clone for LogContext
Source§fn clone(&self) -> LogContext
fn clone(&self) -> LogContext
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 LogContext
impl Debug for LogContext
Auto Trait Implementations§
impl !RefUnwindSafe for LogContext
impl !UnwindSafe for LogContext
impl Freeze for LogContext
impl Send for LogContext
impl Sync for LogContext
impl Unpin for LogContext
impl UnsafeUnpin for LogContext
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