Target::Pipe
does not auto-flush like std{out/err}
#278
Labels
Milestone
Target::Pipe
does not auto-flush like std{out/err}
#278
By default,
env_logger
writes tostderr
usingtermcolor
which defers to thestd::io::Write
implementation ofstd::io::Stderr
. That implementation auto-flushes the buffer when a new line is found.For most cases, this works fine because
log
auto-appends a new line at the end of the record.But when using a custom sink (via
Target::Pipe
), for example - when writing to a file,io::Write::write
is called, butio::Write::flush
is never called.This assumes that the
io::Write::write
implementation of the sink will flush the buffer becausestdout
&stderr
do. But they're outliers in this. Writing does not imply flushing.This also means if for whatever reason the last record isn't newline terminated, that record will be lost. Buffered in memory but never written to the destination.
The text was updated successfully, but these errors were encountered: