-
Notifications
You must be signed in to change notification settings - Fork 144
Description
By default, env_logger writes to stderr using termcolor which defers to the std::io::Write implementation of std::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, but io::Write::flush is never called.
This assumes that the io::Write::write implementation of the sink will flush the buffer because stdout & 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.