spdlog
spdlog copied to clipboard
Blocking flush on async_logger
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.
Try call spdlog::shutdown()
.
Further logging is then impossible:
C++ exception with description "async log: thread pool doesn't exist anymore" thrown in the test body.
Yes. spdlog::shutdown()
should be called just before the application exit.
I realize this is feature request.
Best API (IMO) would be for flush to return std::future
. But separate flush methods are ok too.