Skip to main content

FormatterPort

Trait FormatterPort 

Source
pub trait FormatterPort: Send + Sync {
    // Required method
    fn format(&self, entry: &LogEntry) -> Result<String, ObservabilityError>;
}
Expand description

Port for formatting log entries

Different formatters can be plugged in:

  • JsonFormatter (structured JSON output)
  • PlainTextFormatter (human-readable text)
  • CompactFormatter (single-line JSON)

Required Methods§

Source

fn format(&self, entry: &LogEntry) -> Result<String, ObservabilityError>

Format a log entry into a string

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§