pub struct LogContext {
pub correlation_id: Option<CorrelationId>,
pub trace_id: Option<String>,
pub span_id: Option<String>,
pub user_id: Option<String>,
pub session_id: Option<String>,
pub request_id: Option<String>,
pub service_name: String,
pub operation: Option<String>,
pub attributes: HashMap<String, String>,
}Expand description
Context for structured logging
Fields§
§correlation_id: Option<CorrelationId>§trace_id: Option<String>§span_id: Option<String>§user_id: Option<String>§session_id: Option<String>§request_id: Option<String>§service_name: String§operation: Option<String>§attributes: HashMap<String, String>Implementations§
Source§impl LogContext
impl LogContext
Sourcepub fn from_correlation_context(context: &CorrelationContext) -> Self
pub fn from_correlation_context(context: &CorrelationContext) -> Self
Create log context from correlation context
Sourcepub fn from_trace_context(
trace_context: &TraceContext,
service_name: impl Into<String>,
) -> Self
pub fn from_trace_context( trace_context: &TraceContext, service_name: impl Into<String>, ) -> Self
Create log context from trace context
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add an attribute to the context
Sourcepub fn with_user_id(self, user_id: impl Into<String>) -> Self
pub fn with_user_id(self, user_id: impl Into<String>) -> Self
Set user ID
Sourcepub fn with_session_id(self, session_id: impl Into<String>) -> Self
pub fn with_session_id(self, session_id: impl Into<String>) -> Self
Set session ID
Sourcepub fn with_operation(self, operation: impl Into<String>) -> Self
pub fn with_operation(self, operation: impl Into<String>) -> Self
Set operation
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 · 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<'de> Deserialize<'de> for LogContext
impl<'de> Deserialize<'de> for LogContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LogContext
impl RefUnwindSafe for LogContext
impl Send for LogContext
impl Sync for LogContext
impl Unpin for LogContext
impl UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more