pub struct LogContext {
pub local: LogFields,
pub inherited: LogFields,
}Expand description
A set of fields that can be attached to a logging scope.
Fields are split into two categories:
- local - fields belonging only to the current scope. They do not propagate to child scopes.
- inherited - fields that automatically flow into all child scopes created within the current scope.
Nested scopes resolution rules:
- child
inheritedoverwrites parentinheritedby key - inherited are emitted before local, so “last write wins” consumers see local shadowing
Fields§
§local: LogFieldsFields belonging only to the current scope.
inherited: LogFieldsFields that automatically flow into all child scopes created within the current scope.
Implementations§
Source§impl LogContext
impl LogContext
Sourcepub fn with_local_field(
self,
key: impl Into<Cow<'static, str>>,
value: impl Into<LogValue>,
) -> Self
pub fn with_local_field( self, key: impl Into<Cow<'static, str>>, value: impl Into<LogValue>, ) -> Self
Adds a key-value field to the local fields of this context.
See LogFields for more details about log fields.
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
Source§impl Default for LogContext
impl Default for LogContext
Source§fn default() -> LogContext
fn default() -> LogContext
Returns the “default value” for a type. Read more
Source§impl LogContextExt for LogContext
impl LogContextExt 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