Trait FormatterTrait

Source
pub trait FormatterTrait:
    Send
    + Sync
    + Debug {
    // Required methods
    fn fmt(&self, record: &Record) -> String;
    fn with_colors(&mut self, use_colors: bool);
    fn with_timestamp(&mut self, include_timestamp: bool);
    fn with_level(&mut self, include_level: bool);
    fn with_module(&mut self, include_module: bool);
    fn with_location(&mut self, include_location: bool);
    fn with_pattern(&mut self, pattern: String);
    fn with_format(&mut self, format_fn: FormatFn);
    fn box_clone(&self) -> Box<dyn FormatterTrait + Send + Sync>;

    // Provided method
    fn fmt_batch(&self, records: &[Record]) -> String { ... }
}
Expand description

A trait for formatters that format log records

Required Methods§

Source

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

Format a single record into a string

Source

fn with_colors(&mut self, use_colors: bool)

Enable or disable colored output

Source

fn with_timestamp(&mut self, include_timestamp: bool)

Enable or disable timestamp output

Source

fn with_level(&mut self, include_level: bool)

Enable or disable level output

Source

fn with_module(&mut self, include_module: bool)

Enable or disable module output

Source

fn with_location(&mut self, include_location: bool)

Enable or disable location output

Source

fn with_pattern(&mut self, pattern: String)

Set the pattern for formatting

Source

fn with_format(&mut self, format_fn: FormatFn)

Set a custom format function

Source

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

Clone the formatter into a boxed trait object

Provided Methods§

Source

fn fmt_batch(&self, records: &[Record]) -> String

Format multiple records into a string (default implementation)

Implementors§