Struct flexi_logger::Logger [] [src]

pub struct Logger { /* fields omitted */ }

The standard entry-point for using flexi_logger.

Create a Logger with your desired loglevel-specification

use its configuration methods, and finally call start().

Examples

Use defaults only

If you initialize flexi_logger like this, it behaves like env_logger:

use flexi_logger::Logger;

Logger::with_env().start().unwrap();

Write to files, use a detailed log-line format that contains the module and line number

Here we configure flexi_logger to write log entries with time and location info into a log file in folder "log_files", and we provide the loglevel-specification programmatically, as String:

use flexi_logger::{Logger,opt_format};

Logger::with_str("myprog=debug, mylib=warn")
            .log_to_file()
            .directory("log_files")
            .format(opt_format)
            .start()
            .unwrap_or_else(|e|{panic!("Logger initialization failed with {}",e)});

Methods

impl Logger
[src]

Create a Logger that you provide with an explicit LogSpecification.

Create a Logger that reads the LogSpecification from a String or &str.

Create a Logger that reads the LogSpecification from the environment variable RUST_LOG.

Makes the logger write all logs to a file, rather than to stderr.

Makes the logger print an info message to stdout when a new file is used for log-output.

Makes the logger write all logged error messages additionally to stdout.

Makes the logger write all logged error, warning, and info messages additionally to stdout.

Makes the logger use the provided format function for the log entries, rather than the default (formats::default_format).

Specifies a folder for the log files.

This parameter only has an effect if log_to_file is set to true. If the specified folder does not exist, the initialization will fail. By default, the log files are created in the folder where the program was started.

Specifies a suffix for the log files.

This parameter only has an effect if log_to_file is set to true.

Makes the logger include a timestamp into the names of the log files (log_to_file must be chosen, too).

This option only has an effect if log_to_file is used, too.

By default, the log file will grow indefinitely. With this option, when the log file reaches or exceeds the specified file size, the file will be closed and a new file will be opened. Also he filename pattern changes - instead of the timestamp a serial number is included into the filename.

This option only has an effect if log_to_file is used, too.

The specified String is added to the log file name.

This option only has an effect if log_to_file is used, too.

The specified String will be used on linux systems to create in the current folder a symbolic link to the current log file.

Consumes the Logger object and initializes the flexi_logger.