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[src]
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}, {response-time}, and {ip-addr}.
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:
blackbluebrightblackbrightbluebrightcyanbrightgreenbrightmagentabrightredbrightwhitebrightyellowcyangreenmagentaredwhiteyellow
Available attributes are:
bolddimitalicunderlineblinkstandoutreversesecure
Trait Implementations
impl Clone for Format[src]
fn clone(&self) -> Format
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more
impl Default for Format[src]
fn default() -> Format
Return the default formatting style for the Logger:
@[bold]{method}@ {uri} @[bold]->@ @[C]{status}@ ({response-time}) // This will be written as: {method} {uri} -> {status} ({response-time}) // with certain style attributes.
The method is in bold, and the response status is colored blue for 100s, green for 200s, yellow for 300s, red for 400s, and bright red for 500s.