pub trait ContextPort: Send + Sync {
// Required methods
fn get_context(&self) -> HashMap<String, Value>;
fn add_context(&self, key: String, value: Value);
fn remove_context(&self, key: &str);
fn clear_context(&self);
}Expand description
Port for accessing context information
This allows the logging system to enrich entries with context:
- Agent ID, request ID, trace ID
- User-defined context fields
- Thread/task local context
Required Methods§
Sourcefn get_context(&self) -> HashMap<String, Value>
fn get_context(&self) -> HashMap<String, Value>
Get current context fields
Sourcefn add_context(&self, key: String, value: Value)
fn add_context(&self, key: String, value: Value)
Add a context field
Sourcefn remove_context(&self, key: &str)
fn remove_context(&self, key: &str)
Remove a context field
Sourcefn clear_context(&self)
fn clear_context(&self)
Clear all context
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".