Skip to main content

Logger

Trait Logger 

pub trait Logger {
    type LogRecord: LogRecord;

    // Required methods
    fn create_log_record(&self) -> Self::LogRecord;
    fn emit(&self, record: Self::LogRecord);
    fn event_enabled(
        &self,
        level: Severity,
        target: &str,
        name: Option<&str>,
    ) -> bool;
}
Available on crate features logs and opentelemetry only.
Expand description

The interface for emitting LogRecords.

Required Associated Types§

type LogRecord: LogRecord

Specifies the LogRecord type associated with this logger.

Required Methods§

fn create_log_record(&self) -> Self::LogRecord

Creates a new log record builder.

fn emit(&self, record: Self::LogRecord)

Emit a LogRecord. If there is active current thread’s Context, the logger will set the record’s TraceContext to the active trace context,

fn event_enabled( &self, level: Severity, target: &str, name: Option<&str>, ) -> bool

Check if the given log is enabled.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§