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

Blocking flush on async_logger #1696

Open
mateuszzz88 opened this issue Oct 7, 2020 · 4 comments
Open

Blocking flush on async_logger #1696

mateuszzz88 opened this issue Oct 7, 2020 · 4 comments

Comments

@mateuszzz88
Copy link

spdlog::async_logger::flush() is non-blocking operation. Flush is scheduled for later.
I would like to have blocking variant that will wait untill everything that was scheduled for logging untill now is flushed by all sinks.
My usecase is that I want to be be sure that everything I wanted to log is safe on disk and can be passed for further processing outside program.
Frankly I don't see value in flush operation that doesn't flush NOW and only promises it will be done later. It will be done later anyway, at shutdown at latest.

@tt4g
Copy link
Contributor

tt4g commented Oct 7, 2020

Try call spdlog::shutdown().

@mateuszzz88
Copy link
Author

Further logging is then impossible:
C++ exception with description "async log: thread pool doesn't exist anymore" thrown in the test body.

@tt4g
Copy link
Contributor

tt4g commented Oct 7, 2020

Yes. spdlog::shutdown() should be called just before the application exit.

@mateuszzz88
Copy link
Author

I realize this is feature request.
Best API (IMO) would be for flush to return std::future. But separate flush methods are ok too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants