Struct flexi_logger::LogConfig [] [src]

pub struct LogConfig {
    pub format: fn(&LogRecord) -> String,
    pub log_to_file: bool,
    pub print_message: bool,
    pub duplicate_error: bool,
    pub duplicate_info: bool,
    pub directory: Option<String>,
    pub suffix: Option<String>,
    pub rotate_over_size: Option<usize>,
    pub discriminant: Option<String>,
}

Allows influencing the behavior of flexi_logger.

Fields

format: fn(&LogRecord) -> String

Allows providing a custom logline format; by default flexi_logger::default_format is used. You can either choose between three predefined variants, default_format, opt_format and detailed_format, or you create and use your own format function with the signature fn(&LogRecord) -> String.

log_to_file: bool
  • If false (default), the log is written to stderr.
  • If true, a new file is created and the log is written to it. The default pattern for the filename is '<program_name>_<date>_<time>.<suffix>', e.g. myprog_2015-07-08_10-44-11.log.

Note that all following members of LogConfig are only relevant if this one is set to true.

print_message: bool

If true (default), the name of the logfile is documented in a message to stdout.

duplicate_error: bool

If true (default), all logged error messages are duplicated to stdout.

duplicate_info: bool

If true (default), all logged warning and info messages are also duplicated to stdout.

directory: Option<String>

Allows specifying a directory in which the log files are created. Default is None.

suffix: Option<String>

Allows specifying the filesystem suffix of the log files (without the dot). Default is log.

rotate_over_size: Option<usize>

Allows specifying a maximum size for log files in bytes; when the specified file size is reached or exceeded, the file will be closed and a new one will be opened. The filename pattern changes - instead of the timestamp the serial number is included into the filename.

discriminant: Option<String>

Allows specifying an additional part of the log file name that is inserted after the program name.

Methods

impl LogConfig
[src]

fn new() -> LogConfig

initializes with

  • log_to_file = false,
  • print_message = true,
  • duplicate_error = true,
  • duplicate_info = false,
  • format = flexi_logger::default_format,
  • no directory (log files are created where the program was started),
  • no rotate_over: log file grows indefinitely
  • no discriminant: log file name consists only of progname, date or rotate_idx, and suffix.
  • suffix = "log".