Skip to main content

ContextPort

Trait ContextPort 

Source
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§

Source

fn get_context(&self) -> HashMap<String, Value>

Get current context fields

Source

fn add_context(&self, key: String, value: Value)

Add a context field

Source

fn remove_context(&self, key: &str)

Remove a context field

Source

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".

Implementors§