pub struct FileSink { /* private fields */ }
Expand description
A sink with a file as the target.
It writes logs to a single file. If you want to automatically rotate into
multiple files, see RotatingFileSink
.
The file and directories will be created recursively if they do not exist.
§Examples
See ./examples directory.
Implementations§
Source§impl FileSink
impl FileSink
Sourcepub fn builder() -> FileSinkBuilder<()>
pub fn builder() -> FileSinkBuilder<()>
Gets a builder of FileSink
with default parameters:
Parameter | Default Value |
---|---|
level_filter | All |
formatter | FullFormatter |
error_handler | ErrorHandler::default() |
path | must be specified |
truncate | false |
capacity | consistent with std |
Sourcepub fn new<P>(path: P, truncate: bool) -> Result<FileSink>
👎Deprecated since 0.3.0: it may be removed in the future, use FileSink::builder()
instead
pub fn new<P>(path: P, truncate: bool) -> Result<FileSink>
FileSink::builder()
insteadConstructs a FileSink
.
If the parameter truncate
is true
, the existing contents of the file
will be discarded.
§Error
If an error occurs opening the file, Error::CreateDirectory
or
Error::OpenFile
will be returned.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FileSink
impl !RefUnwindSafe for FileSink
impl Send for FileSink
impl Sync for FileSink
impl Unpin for FileSink
impl !UnwindSafe for FileSink
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
Mutably borrows from an owned value. Read more
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<S> SinkPropAccess for Swhere
S: GetSinkProp,
impl<S> SinkPropAccess for Swhere
S: GetSinkProp,
Source§fn level_filter(&self) -> LevelFilter
fn level_filter(&self) -> LevelFilter
Gets the log level filter.
Source§fn set_level_filter(&self, level_filter: LevelFilter)
fn set_level_filter(&self, level_filter: LevelFilter)
Sets the log level filter.
Source§fn set_formatter(&self, formatter: Box<dyn Formatter>)
fn set_formatter(&self, formatter: Box<dyn Formatter>)
Sets the formatter.
Source§fn set_error_handler(&self, handler: ErrorHandler)
fn set_error_handler(&self, handler: ErrorHandler)
Sets a error handler. Read more