Trait FormatTrait

Source
pub trait FormatTrait:
    Display
    + DynClone
    + Send
    + Sync {
    // Required method
    fn format(&self, log_entry: &LogEntry) -> String;

    // Provided method
    fn ft_fmt(
        &self,
        dt_fmt: String,
        fmt: String,
        log_entry: &LogEntry,
    ) -> String { ... }
}
Expand description

Provides methods for formatting LogEntrys.

Required Methods§

Source

fn format(&self, log_entry: &LogEntry) -> String

Use this method to setup the parameters for calling ft_fmt().

§Parameters
  • log_entry A reference to the LogEntry to be formatted.
§Examples
impl FormatTrait for SimpleFormatter {
    fn format(&self, log_entry: &LogEntry) -> String {
        self.ft_fmt(self.dt_fmt(), self.fmt_string(), log_entry)
    }
}

Provided Methods§

Source

fn ft_fmt(&self, dt_fmt: String, fmt: String, log_entry: &LogEntry) -> String

This method does the actual formatting of the log_entry.

§Parameters
  • dt_fmt - The chrono::DateTime format string.
  • fmt - The primary format string.
    Available variables:
    • mod_path - The module path, possibly supplied via: module_path!().
    • fn_name - The name of the function/method inside which the log entry was generated. Supplied by the #[logger] macro, or manually with the set_fn_name() method instead.
    • level - The log level for which the entry was created.
    • message - The text of the log entry.

Trait Implementations§

Source§

impl Debug for dyn FormatTrait

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§