Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to flush log output or disable buffering #226

Closed
mgrand opened this issue Feb 9, 2022 · 3 comments
Closed

Need to flush log output or disable buffering #226

mgrand opened this issue Feb 9, 2022 · 3 comments
Labels

Comments

@mgrand
Copy link

mgrand commented Feb 9, 2022

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?

@morrisonlevi
Copy link

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.

@KodrAus
Copy link
Collaborator

KodrAus commented May 25, 2022

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.

@epage epage added the bug label Nov 10, 2022
@epage
Copy link
Contributor

epage commented Jan 18, 2024

#296 changed our flushing and so I'm assuming this is fixed and closing. If not, let us know!

@epage epage closed this as completed Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants