Skip to main content

StructuredLogger

Trait StructuredLogger 

Source
pub trait StructuredLogger: Send + Sync {
    // Required methods
    fn log_with_trace(
        &self,
        level: LogLevel,
        message: &str,
        fields: &JsonValue,
        trace_id: Option<&str>,
        span_id: Option<&str>,
    );
    fn log_performance(
        &self,
        operation: &str,
        duration: Duration,
        success: bool,
        additional_fields: &JsonValue,
    );
    fn log_error(&self, error: &dyn Error, context: &JsonValue);
    fn set_level(&mut self, level: LogLevel);
    fn is_level_enabled(&self, level: LogLevel) -> bool;
}
Expand description

Trait for structured logging

Required Methods§

Source

fn log_with_trace( &self, level: LogLevel, message: &str, fields: &JsonValue, trace_id: Option<&str>, span_id: Option<&str>, )

Log with trace context correlation

Source

fn log_performance( &self, operation: &str, duration: Duration, success: bool, additional_fields: &JsonValue, )

Log performance metrics

Source

fn log_error(&self, error: &dyn Error, context: &JsonValue)

Log errors with context

Source

fn set_level(&mut self, level: LogLevel)

Set the minimum log level

Source

fn is_level_enabled(&self, level: LogLevel) -> bool

Check if a level is enabled

Implementors§

Source§

impl StructuredLogger for NoOpStructuredLogger

Available on crate feature structured-logging only.