Trait FormatterTrait

Source
pub trait FormatterTrait:
    Send
    + Sync
    + Debug {
    // Required methods
    fn format(&self, record: &Record) -> String;
    fn with_colors(self, use_colors: bool) -> Self
       where Self: Sized;
    fn with_timestamp(self, include_timestamp: bool) -> Self
       where Self: Sized;
    fn with_level(self, include_level: bool) -> Self
       where Self: Sized;
    fn with_module(self, include_module: bool) -> Self
       where Self: Sized;
    fn with_location(self, include_location: bool) -> Self
       where Self: Sized;
    fn with_pattern(self, pattern: impl Into<String>) -> Self
       where Self: Sized;
    fn with_format<F>(self, format_fn: F) -> Self
       where F: Fn(&Record) -> String + Send + Sync + 'static,
             Self: Sized;
    fn box_clone(&self) -> Box<dyn FormatterTrait + Send + Sync>;
}
Expand description

A trait for formatters that format log records

Required Methods§

Source

fn format(&self, record: &Record) -> String

Format a log record

Source

fn with_colors(self, use_colors: bool) -> Self
where Self: Sized,

Set whether to use colors

Source

fn with_timestamp(self, include_timestamp: bool) -> Self
where Self: Sized,

Set whether to include timestamps

Source

fn with_level(self, include_level: bool) -> Self
where Self: Sized,

Set whether to include the log level

Source

fn with_module(self, include_module: bool) -> Self
where Self: Sized,

Set whether to include the module path

Source

fn with_location(self, include_location: bool) -> Self
where Self: Sized,

Set whether to include the file and line number

Source

fn with_pattern(self, pattern: impl Into<String>) -> Self
where Self: Sized,

Set the format pattern

Source

fn with_format<F>(self, format_fn: F) -> Self
where F: Fn(&Record) -> String + Send + Sync + 'static, Self: Sized,

Set a custom format function

Source

fn box_clone(&self) -> Box<dyn FormatterTrait + Send + Sync>

Clone the formatter

Implementors§