pub struct FileLogWriter { /* private fields */ }Expand description
Implementations§
Source§impl FileLogWriter
impl FileLogWriter
Sourcepub fn builder(file_spec: FileSpec) -> FileLogWriterBuilder
pub fn builder(file_spec: FileSpec) -> FileLogWriterBuilder
Instantiates a builder for FileLogWriter.
Sourcepub fn format(
&self,
) -> fn(&mut dyn Write, &mut DeferredNow, &Record<'_>) -> Result<(), Error>
pub fn format( &self, ) -> fn(&mut dyn Write, &mut DeferredNow, &Record<'_>) -> Result<(), Error>
Returns a reference to its configured output format function.
Sourcepub fn reset(&self, flwb: &FileLogWriterBuilder) -> Result<(), FlexiLoggerError>
pub fn reset(&self, flwb: &FileLogWriterBuilder) -> Result<(), FlexiLoggerError>
Replaces parts of the configuration of the file log writer.
Note that the write mode and the format function cannot be reset and
that the provided FileLogWriterBuilder must have the same values for these as the
current FileLogWriter.
§Errors
FlexiLoggerError::Reset if a reset was tried with a different write mode.
FlexiLoggerError::Io if the specified path doesn’t work.
FlexiLoggerError::OutputBadDirectory if the specified path is not a directory.
FlexiLoggerError::Poison if some mutex is poisoned.
Sourcepub fn config(&self) -> Result<FileLogWriterConfig, FlexiLoggerError>
pub fn config(&self) -> Result<FileLogWriterConfig, FlexiLoggerError>
Returns the current configuration of the file log writer
§Errors
FlexiLoggerError::Poison if some mutex is poisoned.
Sourcepub fn reopen_outputfile(&self) -> Result<(), FlexiLoggerError>
pub fn reopen_outputfile(&self) -> Result<(), FlexiLoggerError>
Makes the FileLogWriter re-open the current log file.
FileLogWriter expects that nobody else modifies the file to which it writes,
and offers capabilities to rotate, compress, and clean up log files.
However, if you use tools like linux’ logrotate
to rename or delete the current output file, you need to inform the FileLogWriter about
such actions by calling this method. Otherwise the FileLogWriter will not stop
writing to the renamed or even deleted file!
§Example
logrotate e.g. can be configured to send a SIGHUP signal to your program. You should
handle SIGHUP in your program explicitly,
e.g. using a crate like ctrlc,
and call this function from the registered signal handler.
§Errors
FlexiLoggerError::Poison if some mutex is poisoned.
Trait Implementations§
Source§impl Debug for FileLogWriter
impl Debug for FileLogWriter
Source§impl Drop for FileLogWriter
impl Drop for FileLogWriter
Source§impl LogWriter for FileLogWriter
impl LogWriter for FileLogWriter
Source§fn write(&self, now: &mut DeferredNow, record: &Record<'_>) -> Result<(), Error>
fn write(&self, now: &mut DeferredNow, record: &Record<'_>) -> Result<(), Error>
Source§fn max_log_level(&self) -> LevelFilter
fn max_log_level(&self) -> LevelFilter
Auto Trait Implementations§
impl Freeze for FileLogWriter
impl RefUnwindSafe for FileLogWriter
impl Send for FileLogWriter
impl Sync for FileLogWriter
impl Unpin for FileLogWriter
impl UnsafeUnpin for FileLogWriter
impl UnwindSafe for FileLogWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<A> DynCastExt for A
impl<A> DynCastExt for A
Source§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,
Source§fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
Source§fn dyn_cast_adv<F, T>(
self,
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
fn dyn_cast_adv<F, T>( self, ) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
Source§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>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more