Closed mgrand closed 7 months ago
For whatever reason, the library is not implementing flush: https://github.com/env-logger-rs/env_logger/blob/52a3e69b38f69469b77502651992f91bdfebb48a/src/lib.rs#L974.
I cannot immediately see through the Writer abstractions to see how to call .flush
on the target or I would just open the PR. In my case I'm using a std::fs::File
that comes from a libc::dup(libc::STDERR_FILENO)
and after a certain point in the program the output no longer shows up, and I believe it's because there isn't a flush. If I don't use env_logger
and just write to the File
at the same point in the program, it shows up.
Originally, env_logger
only supported synchronous output to the terminal, so it didn't have anything to flush. It sounds like things might be a little different now so there's probably some work to do to expose a flush
method on whatever writer is configured and call that from Log::flush
.
I have a unit test that is testing some threading stuff that is hanging. There are many calls to the logging macros that are trying to give me information that will be useful for tracking down the problem.
I never see the log output. The thread hangs before the output is flushed. I know the async call that causes the problem. If I comment that call out I see all my log output. I need to log output to be flushed immediately or have a way to force it to flush.
Does anyone know how I can get log output to be written to the console immediately?