Struct flexi_logger::writers::FileLogWriter
source · 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) -> 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.