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
sourceimpl<W> WriteSink<W>where
W: Write + Send,
impl<W> WriteSink<W>where
W: Write + Send,
sourcepub fn builder() -> WriteSinkBuilder<W, ()>
pub fn builder() -> WriteSinkBuilder<W, ()>
Constructs a builder of WriteSink
.
sourcepub fn with_target<F, R>(&self, callback: F) -> Rwhere
F: FnOnce(&mut W) -> R,
pub fn with_target<F, R>(&self, callback: F) -> Rwhere
F: FnOnce(&mut W) -> 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.