Logger

Trait Logger 

Source
pub trait Logger: Clone + Debug {
    // Required method
    fn write(&self, msg: String);

    // Provided methods
    fn info(&self, msg: impl AsRef<str>, context: Option<&Context>) { ... }
    fn warn(&self, msg: impl AsRef<str>, context: Option<&Context>) { ... }
    fn error(&self, msg: impl AsRef<str>, context: Option<&Context>) { ... }
    fn format_log(
        &self,
        msg: impl AsRef<str>,
        level: &str,
        context: Option<&Context>,
    ) -> String { ... }
}

Required Methods§

Source

fn write(&self, msg: String)

Write the message somewhere.

Provided Methods§

Source

fn info(&self, msg: impl AsRef<str>, context: Option<&Context>)

Log an INFO message.

Source

fn warn(&self, msg: impl AsRef<str>, context: Option<&Context>)

Log a WARN message.

Source

fn error(&self, msg: impl AsRef<str>, context: Option<&Context>)

Log an ERROR message.

Source

fn format_log( &self, msg: impl AsRef<str>, level: &str, context: Option<&Context>, ) -> String

Formatter for all log messages.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Logger for DefaultLogger

By default, print to stderr.