Struct otter_api_tests::flexi_logger::writers::FileLogWriterBuilder [−]
pub struct FileLogWriterBuilder { /* fields omitted */ }Builder for FileLogWriter.
Implementations
impl FileLogWriterBuilder
Simple methods for influencing the behavior of the FileLogWriter.
#[must_use]pub fn print_message(self) -> FileLogWriterBuilder
Makes the FileLogWriter print an info message to stdout
when a new file is used for log-output.
pub fn format(
self,
format: fn(&mut dyn Write, &mut DeferredNow, &Record<'_>) -> Result<(), Error>
) -> FileLogWriterBuilder
self,
format: fn(&mut dyn Write, &mut DeferredNow, &Record<'_>) -> Result<(), Error>
) -> FileLogWriterBuilder
Makes the FileLogWriter use the provided format function for the log entries,
rather than the default (formats::default_format).
pub fn directory<P>(self, directory: P) -> FileLogWriterBuilder where
P: Into<PathBuf>,
P: Into<PathBuf>,
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.
pub fn suffix<S>(self, suffix: S) -> FileLogWriterBuilder where
S: Into<String>,
S: Into<String>,
Specifies a suffix for the log files. The default is “log”.
#[must_use]pub fn suppress_timestamp(self) -> FileLogWriterBuilder
Makes the logger not include a timestamp into the names of the log files
#[must_use]pub fn cleanup_in_background_thread(
self,
use_background_thread: bool
) -> FileLogWriterBuilder
self,
use_background_thread: bool
) -> FileLogWriterBuilder
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.
#[must_use]pub fn rotate(
self,
criterion: Criterion,
naming: Naming,
cleanup: Cleanup
) -> FileLogWriterBuilder
self,
criterion: Criterion,
naming: Naming,
cleanup: Cleanup
) -> FileLogWriterBuilder
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.
#[must_use]pub fn append(self) -> FileLogWriterBuilder
Makes the logger append to the given file, if it exists; by default, the file would be truncated.
pub fn discriminant<S>(self, discriminant: S) -> FileLogWriterBuilder where
S: Into<String>,
S: Into<String>,
The specified String is added to the log file name.
pub fn basename<S>(self, basename: S) -> FileLogWriterBuilder where
S: Into<String>,
S: Into<String>,
The specified String is used as the basename of the log file name, instead of the program name.
pub fn create_symlink<P>(self, symlink: P) -> FileLogWriterBuilder where
P: Into<PathBuf>,
P: Into<PathBuf>,
The specified String will be used on linux systems to create in the current folder a symbolic link to the current log file.
#[must_use]pub fn use_windows_line_ending(self) -> FileLogWriterBuilder
Use Windows line endings, rather than just \n.
#[must_use]pub fn use_buffering(self, buffer: bool) -> FileLogWriterBuilder
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.
#[must_use]pub fn buffer_with_capacity(self, capacity: usize) -> FileLogWriterBuilder
Activates buffering, and uses a buffer with the specified capacity.
pub fn try_build(self) -> Result<FileLogWriter, FlexiLoggerError>
impl FileLogWriterBuilder
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.
#[must_use]pub fn o_print_message(self, print_message: bool) -> FileLogWriterBuilder
With true, makes the FileLogWriterBuilder print an info message to stdout, each time
when a new file is used for log-output.
pub fn o_directory<P>(self, directory: Option<P>) -> FileLogWriterBuilder where
P: Into<PathBuf>,
P: Into<PathBuf>,
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.
#[must_use]pub fn o_timestamp(self, use_timestamp: bool) -> FileLogWriterBuilder
With true, makes the FileLogWriterBuilder include a timestamp into the names of the
log files.
#[must_use]pub fn o_rotate(
self,
rotate_config: Option<(Criterion, Naming, Cleanup)>
) -> FileLogWriterBuilder
self,
rotate_config: Option<(Criterion, Naming, Cleanup)>
) -> FileLogWriterBuilder
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.
#[must_use]pub fn o_append(self, append: bool) -> FileLogWriterBuilder
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.
pub fn o_discriminant<S>(self, discriminant: Option<S>) -> FileLogWriterBuilder where
S: Into<String>,
S: Into<String>,
The specified String is added to the log file name.
pub fn o_basename<S>(self, basename: Option<S>) -> FileLogWriterBuilder where
S: Into<String>,
S: Into<String>,
The specified String is used as the basename of the log file,
instead of the program name, which is used when None is given.
pub fn o_create_symlink<S>(self, symlink: Option<S>) -> FileLogWriterBuilder where
S: Into<PathBuf>,
S: Into<PathBuf>,
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
impl RefUnwindSafe for FileLogWriterBuilder
impl Send for FileLogWriterBuilder
impl Sync for FileLogWriterBuilder
impl Unpin for FileLogWriterBuilder
impl UnwindSafe for FileLogWriterBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
Notable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<A> DynCastExt for A
pub fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
T: ?Sized,
A: DynCastExtHelper<T>,
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
T: ?Sized,
A: DynCastExtHelper<T>,
pub fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
T: ?Sized,
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
T: ?Sized,
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
pub fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
T: ?Sized,
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
T: ?Sized,
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
pub fn dyn_cast_with_config<C>(
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,