Struct logger::format::Format [] [src]

pub struct Format(pub Vec<FormatUnit>);

A formatting style for the Logger, consisting of multiple FormatUnits concatenated into one line.

Methods

impl Format

fn new(s: &str, colors: Vec<FormatColor>, attrs: Vec<FormatAttr>) -> Option<Format>

Create a Format from a format string, which can contain the fields {method}, {uri}, {status}, and {response-time}.

Returns None if the format string syntax is incorrect.


Colors and attributes can also be added to the format string within @ delimiters, by specifying them in a space-delimited list within square brackets ([bold italic]). They can be made dependent on the request/response by passing FunctionColor and FunctionAttrs in as the colors and attrs vecs; these colors/attributes will be used sequentially when there is a [C] or [A] marker, respectively ([bold C]).

For example: @[bold C]{status}@ will be formatted based upon the first FormatColor constant or function in the colors vector, yielding a bold and colored response status.

Available colors are:

  • black
  • blue
  • brightblack
  • brightblue
  • brightcyan
  • brightgreen
  • brightmagenta
  • brightred
  • brightwhite
  • brightyellow
  • cyan
  • green
  • magenta
  • red
  • white
  • yellow

Available attributes are:

  • bold
  • dim
  • italic
  • underline
  • blink
  • standout
  • reverse
  • secure

Trait Implementations

impl Default for Format

fn default() -> Format

Derived Implementations

impl Clone for Format

fn clone(&self) -> Format

fn clone_from(&mut self, source: &Self)