Struct otter_api_tests::crates::otter_support::crates::flexi_logger::writers::FileLogWriterBuilder
[−]pub struct FileLogWriterBuilder { /* private fields */ }
Expand description
Builder for FileLogWriter
.
Implementations
impl FileLogWriterBuilder
impl FileLogWriterBuilder
Methods for influencing the behavior of the FileLogWriter
.
pub fn print_message(self) -> FileLogWriterBuilder
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
pub fn format(
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 default_format
.
pub fn cleanup_in_background_thread(
self,
use_background_thread: bool
) -> FileLogWriterBuilder
pub fn cleanup_in_background_thread(
self,
use_background_thread: bool
) -> FileLogWriterBuilder
Influences how the cleanup activities
(finding files, deleting files, optionally compressing files) are done
when rotation is used with some Cleanup
variant.
With the synchronous write modes,
the cleanup activities are done by default in a dedicated background thread, to
minimize the blocking impact on your application.
You can avoid this extra thread by calling this method with
use_background_thread = false
; the cleanup is then done synchronously
by the thread that is currently logging and - by chance - causing a file rotation.
With WriteMode::AsyncWith
,
the cleanup activities are always done by the same background thread
that also does the file I/O, this method then has no effect.
pub fn rotate(
self,
criterion: Criterion,
naming: Naming,
cleanup: Cleanup
) -> FileLogWriterBuilder
pub fn rotate(
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.
pub fn append(self) -> FileLogWriterBuilder
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 use_utc(self) -> FileLogWriterBuilder
pub fn use_utc(self) -> FileLogWriterBuilder
Enforces the use of UTC, rather than local time.
pub fn create_symlink<P>(self, symlink: P) -> FileLogWriterBuilder where
P: Into<PathBuf>,
pub fn create_symlink<P>(self, symlink: P) -> FileLogWriterBuilder where
P: Into<PathBuf>,
The specified String will be used on unix systems to create in the current folder a symbolic link to the current log file.
pub fn use_windows_line_ending(self) -> FileLogWriterBuilder
pub fn use_windows_line_ending(self) -> FileLogWriterBuilder
Use Windows line endings, rather than just \n
.
pub fn write_mode(self, write_mode: WriteMode) -> FileLogWriterBuilder
pub fn write_mode(self, write_mode: WriteMode) -> FileLogWriterBuilder
Sets the write mode for the FileLogWriter
.
See WriteMode
for more (important!) details.
pub fn try_build(self) -> Result<FileLogWriter, FlexiLoggerError>
pub fn try_build(self) -> Result<FileLogWriter, FlexiLoggerError>
pub fn try_build_with_handle(
self
) -> Result<(ArcFileLogWriter, FileLogWriterHandle), FlexiLoggerError>
pub fn try_build_with_handle(
self
) -> Result<(ArcFileLogWriter, FileLogWriterHandle), FlexiLoggerError>
Produces the FileLogWriter
and a handle that is connected with it.
This allows handing out the FileLogWriter
instance to methods that consume it, and still
be able to influence it via the handle.
Errors
FlexiLoggerError::Io
if the specified path doesn’t work.
impl FileLogWriterBuilder
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
.
pub fn o_print_message(self, print_message: bool) -> FileLogWriterBuilder
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_rotate(
self,
rotate_config: Option<(Criterion, Naming, Cleanup)>
) -> FileLogWriterBuilder
pub fn o_rotate(
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.
pub fn o_append(self, append: bool) -> FileLogWriterBuilder
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_create_symlink<S>(self, symlink: Option<S>) -> FileLogWriterBuilder where
S: Into<PathBuf>,
pub fn o_create_symlink<S>(self, symlink: Option<S>) -> FileLogWriterBuilder where
S: Into<PathBuf>,
If a String is specified, it will be used on unix 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<W, Global>impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
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
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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
impl<A> DynCastExt for A
impl<A> DynCastExt for A
fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
A: DynCastExtHelper<T>,
T: ?Sized,
fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
A: DynCastExtHelper<T>,
T: ?Sized,
Use this to cast from one trait object type to another. Read more
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
T: ?Sized,
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
T: ?Sized,
Use this to upcast a trait to one of its supertraits. Read more
fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
T: ?Sized,
fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
T: ?Sized,
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>,
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>,
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more