pub struct WriteSink<W>{ /* private fields */ }
Expand description
A sink that writes log messages into an arbitrary impl Write
object.
§Performance Notice
Since WriteSink
can write into any impl Write
objects, the assumptions
made on the underlying impl Write
object is very weak and this does impact
performance. You should use other sinks or implement your own sinks whenever
possible. WriteSink
is your last resort if no other sinks meet your
requirement.
If you want to log into a file, use FileSink
or RotatingFileSink
instead.
If you want to log into the standard streams, use StdStreamSink
instead.
Implementations§
Source§impl<W> WriteSink<W>
impl<W> WriteSink<W>
Sourcepub fn builder() -> WriteSinkBuilder<W, ()>
pub fn builder() -> WriteSinkBuilder<W, ()>
Gets a builder of WriteSink
with default parameters:
Parameter | Default Value |
---|---|
level_filter | All |
formatter | FullFormatter |
error_handler | default error handler |
target | must be specified |
Sourcepub fn with_target<F, R>(&self, callback: F) -> R
pub fn with_target<F, R>(&self, callback: F) -> R
Invoke a callback function with the underlying impl Write
object.
This function returns whatever the given callback function returns.
Note that this sink cannot write into the underlying impl Write
object
while the given callback function is running. If the underlying
impl Write
object supports a relatively cheap clone
operation,
consider using the clone_target
method.