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 timestamp: bool,
    pub rotate_over_size: Option<usize>,
    pub discriminant: Option<String>,
    pub create_symlink: Option<String>,
}

Internal struct for influencing the behavior of flexi_logger.

This structure is only needed if you want to instantiate multiple loggers in a your process.

Fields

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.

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

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

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

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

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

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

Allows specifying whether or not the filename should include a timestamp. Default is true.

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.

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

Allows specifying an option to create a symlink to the most recent log file created using the given name. Default is None.

Note that this option is only effective on linux systems.

Methods

impl LogConfig
[src]

The defaults for the logger initialization are

  • log_to_file = false
  • print_message = true
  • duplicate_error = true
  • duplicate_info = false
  • format = flexi_logger::default_format
  • no directory: log files (if they were used) are created where the program was started
  • no rotate_over: log file (if it were used) grows indefinitely
  • the name of the log file (if it were used) consists of progname, timestamp, and suffix log
  • no symlink being created.

We recommend using this constructor as described in the examples of function init to avoid compilation issues with your code, if future versions of flexi_logger come with extensions to LogConfig.