Enum flexi_config::LogFormat [] [src]

pub enum LogFormat {
    Default,
    Detailed,
    Opt,
    Custom(String),
    CustomStr(&'static str),
}

Enumeration to set the format of the log messages.

The two custom values (Custom and CustomStr) allow you to specify a custom log format. This format is simular to the ust format style but different to specify the log directive. The basic format is:

format_string := <text> [ format <text> ] *
format :=  '{' type:[[align]width[trim]] '}'
align := '<' | '>'
width := integer
trim := '-' | ''

Align is used to align the text to the left or right, there is no centering. The width is needed for the alignment but can also be used to truncate text to fit inside the specified width.

The trim flag will trim the text if it is greater than the width. If there is no alignment or the alignment is to the left, then the end of the string is trimmed. If the alignment is to the right then the start of the string is trimmed.

The type flag identifies which part of the debug message you want to log. The following values are supported:

  • f - Inserts the file the log message is in.
  • p - Inserts the log priority as a single lowercase letter. 'd' for debug, 'e' for error and so on.
  • P - Inserts the log priority as a single uppercase letter. 'I' for info, 'W' for warning and so on.
  • pp - Inserts the log priority in lowercase, 'trace', 'debug', 'info', 'warn', 'error'.
  • PP - Inserts the log priority in uppercase, 'TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR'.
  • l - Inserts the line number of the log message.
  • m - Inserts the name of the module the file logging the message is in.
  • c - Inserts the crate that is logging the message.
  • t - Inserts the time of the log message.
  • e - Inserts the actual log message.

Examples

To create an output line like:

W| foo.rs:20 | Warning, warning warning.

You could define the following:

LogFormat::CustomStr("{P}|{f:>10-}:{l:<4} | {e}");

Variants

Chooses the flexi_logger default format which would look like:

INFO [my_prog::some_submodule] Task successfully read from conf.json

Chooses the flexi_logger detailed format which would look like:

[2016-01-13 15:25:01.640870 +01:00] INFO [foo::bar] src/foo/bar.rs:26: Task successfully read from conf.json

Chooses the flexi_logger optional format which would look like:

[2016-01-13 15:25:01.640870 +01:00] INFO [src/foo/bar:26] Task successfully read from conf.json

Provides a custom log string.

Provides a custom log string.

Methods

impl LogFormat
[src]

Decodes a string value into the enumeration value. This is use in conjunction with encode().

Converts the enumeration value into a string so it can be saved. Used in conjunction with decode().

Checks if the format has an error. If there are no errors returns None, otherwise returns the error. If the format is a predefined format then the answer is always None.

Returns the log format function that should be used to format the log messages.

If the format is not a standard flexi formatter, this method will initialize the custom log formatter based on the format string. If the format string is invalid then an error describing the problem will be returned.

Trait Implementations

impl Debug for LogFormat
[src]

Formats the value using the given formatter.

impl Eq for LogFormat
[src]

impl PartialEq for LogFormat
[src]

Performs an equality comparison that treams Custom and CustomStr the same if the strings are equivalent.

This method tests for !=.

impl Clone for LogFormat
[src]

Clones the object converting a CustomStr into a Custom if necessary.

Performs copy-assignment from source. Read more