Struct otter_api_tests::flexi_logger::writers::FileLogWriterBuilder[]

pub struct FileLogWriterBuilder { /* fields omitted */ }
Expand description

Builder for FileLogWriter.

Implementations

Simple methods for influencing the behavior of the FileLogWriter.

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

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

Specifies a folder for the log files.

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. The default is “log”.

Makes the logger not include a timestamp into the names of the log files

When rotation is used with some Cleanup variant, then this option defines if the cleanup activities (finding files, deleting files, evtl compressing files) is done in the current thread (in the current log-call), or whether cleanup is delegated to a background thread.

As of flexi_logger version 0.14.7, the cleanup activities are done by default in a background thread. This minimizes the blocking impact to your application caused by IO operations.

In earlier versions of flexi_logger, or if you call this method with use_background_thread = false, the cleanup is done in the thread that is currently causing a file rotation.

Use rotation to prevent indefinite growth of log files.

By default, the log file is fixed while your program is running and will grow indefinitely. With this option being used, when the log file reaches the specified criterion, the file will be closed and a new file will be opened.

Note that also the filename pattern changes:

  • by default, no timestamp is added to the filename
  • the logs are always written to a file with infix _rCURRENT
  • when the rotation criterion is fulfilled, it is closed and renamed to a file with another infix (see Naming), and then the logging continues again to the (fresh) file with infix _rCURRENT.

Example:

After some logging with your program my_prog and rotation with Naming::Numbers, you will find files like

my_prog_r00000.log
my_prog_r00001.log
my_prog_r00002.log
my_prog_rCURRENT.log

The cleanup parameter allows defining the strategy for dealing with older files. See Cleanup for details.

Makes the logger append to the given file, if it exists; by default, the file would be truncated.

The specified String is added to the log file name.

The specified String is used as the basename of the log file name, instead of the program name.

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

Use Windows line endings, rather than just \n.

Define if buffering should be used.

By default, every log line is directly written to the output file, without buffering. This allows seeing new log lines in real time.

Using buffering reduces the program’s I/O overhead, and thus increases overall performance, which can be important if logging is used heavily. On the other hand, if logging is used with low frequency, the log lines can become visible in the output file with significant deferral. See Logger::buffer_and_flush for how to limit the maximum buffering time.

Note that with buffering you should use LogWriter::shutdown at the very end of your program to ensure that all buffered log lines are flushed before the program terminates.

Activates buffering, and uses a buffer with the specified capacity.

See Logger::use_buffering

Produces the FileLogWriter.

Errors

FlexiLoggerError::Io.

Alternative set of methods to control the behavior of the FileLogWriterBuilder. Use these methods when you want to control the settings flexibly, e.g. with commandline arguments via docopts or clap.

With true, makes the FileLogWriterBuilder print an info message to stdout, each time when a new file is used for log-output.

Specifies a folder for the log files.

If the specified folder does not exist, the initialization will fail. With None, the log files are created in the folder where the program was started.

With true, makes the FileLogWriterBuilder include a timestamp into the names of the log files.

By default, and with None, the log file will grow indefinitely. If a rotate_config is set, when the log file reaches or exceeds the specified size, the file will be closed and a new file will be opened. Also the filename pattern changes: instead of the timestamp, a serial number is included into the filename.

The size is given in bytes, e.g. o_rotate_over_size(Some(1_000)) will rotate files once they reach a size of 1 kB.

The cleanup strategy allows delimiting the used space on disk.

If append is set to true, makes the logger append to the given file, if it exists. By default, or with false, the file would be truncated.

The specified String is added to the log file name.

The specified String is used as the basename of the log file, instead of the program name, which is used when None is given.

If a String is specified, it will be used on linux systems to create in the current folder a symbolic link with this name to the current log file.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Use this to cast from one trait object type to another. Read more

Use this to upcast a trait to one of its supertraits. Read more

Use this to cast from one trait object type to another. This method is more customizable than the dyn_cast method. Here you can also specify the “source” trait from which the cast is defined. This can for example allow using casts from a supertrait of the current trait object. Read more

Use this to cast from one trait object type to another. With this method the type parameter is a config type that uniquely specifies which cast should be preformed. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.