Struct flexi_logger::writers::FileLogWriter
source · [−]pub struct FileLogWriter { /* private fields */ }
Expand description
Implementations
sourceimpl 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) -> FormatFunction
pub fn format(&self) -> FormatFunction
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
sourceimpl Debug for FileLogWriter
impl Debug for FileLogWriter
sourceimpl Drop for FileLogWriter
impl Drop for FileLogWriter
sourceimpl LogWriter for FileLogWriter
impl LogWriter for FileLogWriter
sourcefn write(&self, now: &mut DeferredNow, record: &Record<'_>) -> Result<()>
fn write(&self, now: &mut DeferredNow, record: &Record<'_>) -> Result<()>
Writes out a log line. Read more
sourcefn max_log_level(&self) -> LevelFilter
fn max_log_level(&self) -> LevelFilter
Provides the maximum log level that is to be written.
sourcefn format(&mut self, format: FormatFunction)
fn format(&mut self, format: FormatFunction)
Sets the format function. Read more
Auto Trait Implementations
impl !RefUnwindSafe for FileLogWriter
impl Send for FileLogWriter
impl Sync for FileLogWriter
impl Unpin for FileLogWriter
impl !UnwindSafe for FileLogWriter
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more