env_logger icon indicating copy to clipboard operation
env_logger copied to clipboard

Provide a way to disable automatic flushing when using `Target::Pipe`

Open quantatic opened this issue 1 year ago • 1 comments

When using Target::Pipe to log to a file (or another similar buffered output interface), the fact that we flush after each line causes a significant slowdown. It would be awesome to provide some sort of configuration mechanism to disable this automatic flushing after each line, letting the user force flushing at shutdown with log::logger().flush(), if necessary.

It looks like this automatic flushing logic was added here.

quantatic avatar Feb 08 '24 20:02 quantatic

Automatic flushing is the right default due to concerns over crashing, reading pipes while writing continues, etc.

Allowing this to be configurable on the pipe definition would be a breaking change because we just accept a Box from the user and we'd need to change that type.

We could maybe make flushing a logger-wide setting though I'm mixed on that.

epage avatar Feb 09 '24 16:02 epage